[rspec-users] Controller specs and default_url_options

Joshua Muheim
Mon, 12 Nov 2012 15:07:40 -0000

Thanks for these very useful informations.

I found the titinux'' first post to solve my problems with request
specs,
and martin_c94''s post to solve my controller specs problems.

Still, in the console, the url helpers need the locale explicitly set,
it seems:

[1] pry(main)> app.user_path User.first
ActionController::RoutingError: No route matches {:action=>"show",
:controller=>"users", :locale=>#<User _id:
509fc01d77bb1................

Interestingly, when executing the following code block (which is also
used to fix the problem with the request specs) within the console, it
works!

[2] pry(main)> class ActionDispatch::Routing::RouteSet
[2] pry(main)*   def default_url_options(options={})
[2] pry(main)*     { :locale => I18n.default_locale }
[2] pry(main)*   end
[2] pry(main)* end
=> nil
[3] pry(main)> app.user_path User.first
=> "/de/users/509fc01d77bb1e6a050000a0"

I''m not sure whether this would be a valid fix also for the console??
Do
you guys experience the same behavior??

--
Posted via http://www.ruby-forum.com/.