【发布时间】:2015-04-04 12:34:28
【问题描述】:
我正在尝试使 Rails 控制器规范在我的引擎中工作。控制器测试如下所示:
module Notes
describe NotesController do
routes { Notes::Engine.routes }
it 'renders index' do
get 'index'
end
end
end
目前我正在使用Combustion gem 生成的虚拟,所以我的虚拟配置路线是:
# spec/internal/config/routes.rb
require 'notes'
require Notes::Engine.root.join('config/routes')
Rails.application.routes.draw do
mount Notes::Engine => '/', as: 'notes'
# mount Notes::Engine => '/notes'
end
问题 1:
我试图通过安装引擎来避免将引擎路由复制粘贴到虚拟配置文件中。但是,我找不到正确的配置来使 routes { Notes::Engine.routes } 行在我的规范中变得多余。
问题 2:
尝试在我的 Rails 虚拟对象 ./spec/internal 上查找 app/views 文件夹时,控制器规范失败。到目前为止,我通过从spec/internal/app 到我的真实./app 的符号链接解决了这个问题。
有没有更简洁的方式来查找我的观点?我希望 Rails dummy 直接从引擎中提取应用程序文件夹,但没有链接就不会发生。
【问题讨论】:
标签: ruby-on-rails ruby rspec rails-engines