I’m getting http://www.example.com whenever I use root_url in my tests.
It works fine in development, where I have this in config/environments/development.rb:
Rails.application.routes.default_url_options[:host]= 'localhost:3000'
Adding this doesn’t work in config/environments/test.rb, though. What should I add to use localhost:3000 as the host in the test environment?
Testing code that depends on
default_url_optionscauses all kinds of problems, see this thread and this issue for examples.I’ve solved the problem by patching
ActionDispatch::Routing::RouteSetin tests to force rails to include defaults for whatever options I want (in my caselocale). See my answer in the github issue linked to above for details.To override the
hostoption using the same approach:Put this in a file in
support, should do the trick.