I am using rspec, capybara. I set the locale from the http header as below.
before_filter :set_locale def extract_locale_from_accept_language_header request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[az]{2}/).first end def set_locale return I18n.locale = current_user.locale if user_signed_in? I18n.locale = extract_locale_from_accept_language_header || I18n.default_locale end
When I run my test test, I get the "undefined scan for NilClass" method. Capybara does not seem to set http headers.
How to set an HTTP header for all my functions or avoid it in another way?
source share