我试图将规范写入成员控制器操作,该操作假设指向" / admin / projects /:id / some_action&#34 ;, routes.rb文件具有以下内容:
namespace :admin do
resources :projects do
member do
get :some_action
end
end
end
所以,当我运行$ rake路由时,我得到了正确的url / admin / projects /:id / some_action,但是在控制器规范中我遇到了拦截错误。
describe Admin::ProjectsController do
it "should get the action" do
project = mock_model(:project, :id => 1)
get :some_action, {:id => project.id}
end
end
结果总是一样的:
Failure/Error: get :some_action, {:id => 1}
ActionController::RoutingError:
No route matches {:id=>1, :controller=>"admin/projects", :action=>"some_action"}
有人通过这种问题吗?有什么建议可以解决吗?
非常感谢任何帮助,谢谢!