3

I was having a deprecation warning after upgrading to rails 3.2.16. The deprecation was related to enforce_available_locales and I can resolve it by applying solution from this question.

Rails I18n validation deprecation warning

The solution was to add this line in config/application.rb

config.i18n.enforce_available_locales = true

After adding the above line, my rspec tests suddenly become extremely slow. Usually it takes around 0.03-0.1 sec per testcase, now it takes around 2-4 secs per testcase.

Is anyone having the same problem? or is this only apply to my environment?

FYI this is my gems:

gem 'rails', '= 3.2.16'  
gem 'rspec', '~> 2.14.1'  
gem 'rspec-rails', '~> 2.14.0'  
gem 'shoulda', '~> 3.5.0'  
gem 'i18n', '~> 0.6.9'

EDITED:

I found this issue on GitHub i18n, it seems it's not just me..

Community
  • 1
  • 1
giosakti
  • 411
  • 9
  • 18

2 Answers2

1

There's a github issue about that: https://github.com/svenfuchs/i18n/issues/230

The problem has been solved by May 7, 2014 here: https://github.com/svenfuchs/i18n/pull/249

schmijos
  • 8,114
  • 3
  • 50
  • 58
0

I suggest you to use the zeus gem to load the whole environment in a much faster way. You can follow this screencast for more information.

tl%tr

Without adding it to the Gemfile, install the zeus gem (gem install zeus), then run zeus start in a shell. Open another shell and you will have all the common rails command under the zeus shortcut.

When you run your tests with zeus rspec spec/ you will find a very high speed increase, since the whole rails environment is always loaded in memory and do not need to be initialized every time you run a test.

marzapower
  • 5,531
  • 7
  • 38
  • 76
  • 1
    hi, while your answer is correct to speed up overall test performance.. my question is, however, specifically related on enforce_available_locales configuration in application.rb – giosakti Dec 10 '13 at 23:32
  • You are right, and I'm sorry for that. Since you've found the solution, I suggest you to add yourself the correct answer and accept it :) – marzapower Dec 11 '13 at 16:00
  • unfortunately no, it's not the solution.. its just an issue that is being reported to the i18n github. so i'm still stuck with this sluggish performance when setting true to enforce available locales :( – giosakti Dec 12 '13 at 05:01