In my application_controller, I have the following set to include the locale with all paths generated by url_for:
def default_url_options(options={})
{
alias_method_chain
is deprecated in Rails 5, and it seems the Behavior process method has changed.
Here's my modification of Martin Carel's answer above, adapted to Rails 5.
RSpec.configure do |config|
module ActionController
class TestCase
module Behavior
module LocaleParameter
def process(action, parameters = {params: {}})
unless I18n.locale.nil?
parameters[:params][:locale] = I18n.locale
end
super(action, parameters)
end
end
prepend Behavior::LocaleParameter
end
end
end
end
I'm by no means an expert in Rails or Ruby, so if something can be improved in this answer, let me know and I'll change it.