I'm using rails 3.0.5, rspec2 with latest capybara.
Routes setup like:
scope "(:locale)", :locale => /de|fr|it|en/ do
resources :dossiers
end
In application_controller I have this:
def default_url_options(options={})
options[:locale] = "es"
options
end
So in my views I can use
link_to 'test', dossier_path(1)
without any problems.
But when I do the same in capybara's visit it tries to use the 1 for the locale and not for the id. It only works when I use
visit dossier_path(nil, 1)
or
visit dossier_path(:id => 1)
But both are ugly and looks like a dirty hack. So why do I need to use this dirty hack and what do I jave to do, so that I can use the path methods just like in the views (so without the dirty hack of having to add nil or explicitly pass :id => ...)? :)
I ran into a similar issue. You can set the default_url_options in a before block like this in request specs:
before :each do
app.default_url_options = { :locale => :es }
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With