-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to 18n is not playing nice with rails #5
Comments
I just released 0.9.1 which doesn't stomp on the default locale any more. I'll have to take a longer look at the failing test issue. |
And now 0.9.2 is out. :) This version stops clobbering the load path, which may have been the test problem. |
Now is working fine. |
Just got the ripple effect from this. Thanks for the quick fix! |
It's not working for me. The default locale of application don't work in test environment in the 0.9.2 version. The gem change the locale for 'en' and my default locale is 'pt_BR' |
rafael, perhaps you could put together a sample app that shows the problem? |
Sure! It's here: https://github.com/rafaelfranca/faker_test |
rafael, I just pushed some changes that should fix the problem for you (the test app now passes the tests). Also, note the change in the readme about setting locale in Rails. |
Nice! Thanks. |
I'm seeing more of these types of errors: => nil I'm running Rails 3, ruby 1.9.2, and faker 0.9.5. This only happens in Rails Console. It's working fine inside my application. |
I'm having the same problem as lgrains. |
I was having problems running faker on Heroku. The error I was getting was was: rake task error is: private method `rand' called for "translation missing: en.faker.address.street_address":String I was able to fix this by adding the faker version of the locals/en.yml to my heroku repo. |
same problem as Igrains here, with private method `rand' called for "translation missing: en.faker.name.first_name":String faker 0.9.5 (testing a Radiant 0.9.1 extension with rspec 1.1.12) |
Just wanted to comment that I was still running into an issue with this myself with faker 0.9.5. I fixed it by explicitly telling I18n to reload after requiring "faker" in my spec_helper.rb: I18n.reload! For my app, I believe this was because a translation was accessed in an initializer before faker was required. This probably means that I18n loaded everything in the I18n.load_path before faker added to the load path. So even though faker is adding to the load path, it is not forcing a reload of I18n. In most cases this is fine (as in, when no translations are accessed before faker is required), but in my case it was not. @stympy It may be worthwhile forcing an I18n reload after you modify the load_path in the gem anyways; this is probably good practice, just in case. |
Same issue here: private method `rand' called for "translation missing: pt-BR.faker.address.street_address":ActiveSupport::SafeBuffer Whats the fix? |
@maca Check out my last comment - until this is done within the faker gem, you should call this immediately after requiring faker in your spec_helper.rb: I18n.reload! |
Thanks it did the trick, I tried before I had to add gem 'faker', :require => nil to my Gemfile and manually requiring in spec_helper, in the line below I added I18n.reload! |
Hi, I used your last pull with no luck. I still have to manually require faker in my spec_helper instead of using the Gemfile and do the I18n reload. |
It actually works for rspec but not for cucumber my env.rb:
|
Had to switch back to 0.3.1 and ignore deprecation warnings for #returning |
I still have this issue. |
@rubiety thanks for preserving the hair on my head... I spent 30 minutes wondering WTF was going on with Faker inside my FactoryGirl stuff for errors like this:
and your tip worked like a charm!
I also had to do this in environment.rb:
or you can do this:
|
Still have this issue. It appears on Jenkins builds. |
Pulling the gem from github after commit 22a9476 fixed it for me (Rails 3.1 and Ruby 1.9.2). Thanks! |
I'm switch to ffaker gem =) |
I am also setting in config/application.rb
Because I still see a problem that :en locale is taken as default with ruby 1.8.7, Rails 3.0.10 Faker 1.0 |
Setting :en for me was not an option and switching to ffaker worked out well, if someone else still has this issue... |
FWIW I was running into the same issue and none of the above workarounds were, well, working. In my case, I was just not calling the right method. Eg. I was calling |
Faker should not change I18n locale (however this can be easly fixed by setting Faker::Config.locale).
Other problem after updating faker gem, when running specs in rails application is lots of failing tests:
Expected errors to include "translation missing: en.errors.messages.blank" when user_id is set to nil, got errors: user_id translation missing: en.activerecord.errors.models.billing.attributes.user_id.blank (nil)app_id translation missing: en.activerecord.errors.models.billing.attributes.app_id.blank (nil)
Rails 2.3.10, Ruby ree-1.8.7-2010.02
The text was updated successfully, but these errors were encountered: