我有一個路線: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版本? –