1
0
Fork 0
mirror of https://github.com/thoughtbot/shoulda-matchers.git synced 2022-11-09 12:01:38 -05:00

Set I18n.enforce_available_locales correctly

This setting is only available for I18n v0.6.9, so setting it for all
versions of Rails or I18n versions may not work.
This commit is contained in:
Elliot Winkler 2014-01-21 11:34:45 -07:00
parent 2e89471d07
commit ce9c9b8d5b
2 changed files with 23 additions and 2 deletions

View file

@ -24,5 +24,3 @@ RSpec.configure do |config|
config.include Shoulda::Matchers::ActionController,
example_group: { file_path: /action_controller/ }
end
I18n.enforce_available_locales = false

View file

@ -56,9 +56,32 @@ class TestApplication
end
def generate
rails_new
fix_available_locales_warning
end
def rails_new
`rails new #{ROOT_DIR} --skip-bundle`
end
def fix_available_locales_warning
# See here for more on this:
# http://stackoverflow.com/questions/20361428/rails-i18n-validation-deprecation-warning
filename = File.join(ROOT_DIR, 'config/application.rb')
lines = File.read(filename).split("\n")
lines.insert(-3, <<EOT)
if I18n.respond_to?(:enforce_available_locales=)
I18n.enforce_available_locales = false
end
EOT
File.open(filename, 'w') do |f|
f.write(lines.join("\n"))
end
end
def load_environment
require environment_file_path
end