diff options
author | Matthew Landauer <matthew@openaustralia.org> | 2013-03-26 14:30:35 +1100 |
---|---|---|
committer | Matthew Landauer <matthew@openaustralia.org> | 2013-03-26 14:58:10 +1100 |
commit | fd5c8370239ba970776aa345f4485e96a78f96ac (patch) | |
tree | 588bb41bdf4b6284b2d52238ba5582cca8f71246 | |
parent | 35dc277233b3e87dca9a86c1b579c0e4d968b571 (diff) |
Unraveled another test environment cleanup bug with config.order = random:33691
-rw-r--r-- | spec/spec_helper.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c1b2d094c..57ab88da2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -71,6 +71,19 @@ Spork.prefork do ActionMailer::Base.deliveries = [] end + # Any test that messes with the locale needs to restore the state afterwards so that it + # doesn't interfere with any subsequent tests. This is made more complicated by the + # ApplicationController#set_gettext_locale which sets the locale and so you may be setting + # the locale in your tests and not even realising it. So, let's make things easier for + # ourselves and just always restore the locale for all tests. + config.before(:each) do + @save_i18n_locale = I18n.locale + end + + config.after(:each) do + I18n.locale = @save_i18n_locale + end + # This section makes the garbage collector run less often to speed up tests last_gc_run = Time.now |