diff options
author | Mark Longair <mhl@pobox.com> | 2013-11-19 10:24:40 +0000 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-11-19 10:24:40 +0000 |
commit | d4a798bfcaf288125b02e7ad9292048070f635dd (patch) | |
tree | 1453cd457359813e7890fd7577f194e84a36793b /spec/spec_helper.rb | |
parent | 68fc88b88298199190b6bfd4f8d97ab2d2fb62a2 (diff) |
Add a helper method for temporarily setting I18n.default_locale
Although the I18n library has an I18n.with_locale helper, there's
no equivalent for I18n.default_locale. This method will make a
couple of our tests clearer and less brittle.
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 9d16f6387..d22f3c0ff 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -183,6 +183,14 @@ Spork.prefork do end end + def with_default_locale(locale) + original_default_locale = I18n.default_locale + I18n.default_locale = locale + yield + ensure + I18n.default_locale = original_default_locale + end + def load_test_categories PublicBodyCategories.add(:en, [ "Local and regional", |