不使用Cucumber / Capybara的路由范围,默认范围参数在WEBrick中不起作用

时间:2012-01-09 16:05:02

标签: ruby-on-rails ruby-on-rails-3 routes cucumber capybara

我有这条路线来分隔不同代理商的用户:

scope "/:agency" do
  resources :users
end

在ApplicationController中,我已将此行为添加到default_url_options:

def default_url_options(options={})
  { :agency => params[:agency] }
end 

服务器和params [:agency]报告URL中的内容,一切正常。 但是在使用Cucumber + Capybara进行测试时

user_path(1)

变为

http://www.example.com/1/users

而不是

http://www.example.com/theagency/users/1

阅读了一些我试过的文档:

scope "/:agency", :defaults => { :agency => 'test-agency'} do
  resources :users
end

测试似乎正在运行(URL是正确构建的)但实际上所有URL都是使用test-agency构建的,作为第一个参数,无论参数是什么。

是否有任何想法让测试与此设置一起使用?

0 个答案:

没有答案