我有一个路线:Rspec的无路线控制器的规格相匹配
scope '/account' do
get '/' => 'accounts#index', as: :account
end
而且我想使用RSpec来测试它:
describe AccountsController, type: :controller do
it 'renders the index template' do
get :index
expect(response.status).to eq(200)
expect(response).to render_template :index
end
end
但我有:
ActionController::UrlGenerationError: No route matches
如何解决它?
完整的跟踪:
[11] pry(#<RSpec::ExampleGroups::AccountsController>)> get :index
ActionController::UrlGenerationError: No route matches {:action=>"index", :controller=>"accounts"}
from /home/rubydev/.rvm/gems/ruby-2.2.1/gems/actionpack-4.2.5/lib/action_dispatch/journey/formatter.rb:46:in `generate'
请分享错误跟踪跟踪? –
@NarasimhaReddy更新 – Sts
你能否提供整个测试文件,我测试了你的代码,它的工作原理,Rails,Ruby和RSpec版本? –