【发布时间】:2015-08-23 17:32:38
【问题描述】:
我正在尝试测试一个不是 rails 中提供的 restfuls 之一的端点,(i.e: #index, #new, #edit, #update, #create, #destroy)
在我的routes.rb 文件中:
get 'hospitals/:id/doctors' => 'hospitals#our_doctors'
在我的hospitals_controller_spec.rb 文件中:
describe "GET #our_doctors" do
before do
get :our_doctors
end
end
但我遇到以下错误:
ActionController::UrlGenerationError: No route matches {:action=>"our_doctors", :controller=>"hospitals"}
我怎样才能让我的规范遵循所需的路线?
我也试过这样称呼它:
get "/hospitals/#{@hospital.id}/doctors"
但出现以下错误:
ActionController::UrlGenerationError: No route matches {:action=>"/hospitals/1/doctors", :controller=>"hospitals"}
感谢所有帮助,谢谢。
【问题讨论】:
标签: ruby-on-rails rspec routing