鉴于我有一条命名路线:
map.some_route '/some_routes/:id', :controller => 'some', :action => 'other'
如何使用路由规范文件“spec/routing/some_routing_spec.rb”来测试该命名路由?
我在“describe SomeRouteController” block 之后尝试过这个,但它不起作用,我得到“未定义的方法”helper:
describe SomeRouteHelper, 'some routes named routes' do
it 'should recognize some_route' do
helper.some_route_path(23).should == '/some_routes/23'
end
end
最佳答案
如果这是在 Controller 规范中,您可以直接调用路由方法,不需要帮助程序。
describe SomeController do
it 'should recognize ma routes!' do
thing_path(23).should == '/things/23'
end
end
关于ruby-on-rails - 如何使用 rspec 测试命名路由?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1764383/