Comments (29)
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.
from faker.
And now 0.9.2 is out. :) This version stops clobbering the load path, which may have been the test problem.
from faker.
Now is working fine.
Thanks.
from faker.
Just got the ripple effect from this. Thanks for the quick fix!
from faker.
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'
from faker.
rafael, perhaps you could put together a sample app that shows the problem?
from faker.
Sure! It's here: https://github.com/rafaelfranca/faker_test
from faker.
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.
from faker.
Nice! Thanks.
from faker.
I'm seeing more of these types of errors:
=> nil
ruby-1.9.2-p136 :003 > Factory(:merchant)
NoMethodError: private method rand' called for "translation missing: en.faker.name.last_name":String from /Users/lrains/.rvm/gems/ruby-1.9.2-p136@hazzoo/gems/faker-0.9.5/lib/faker.rb:37:in
fetch'
from /Users/lrains/.rvm/gems/ruby-1.9.2-p136@hazzoo/gems/faker-0.9.5/lib/faker/name.rb:10:in last_name' from /Users/lrains/.rvm/gems/ruby-1.9.2-p136@hazzoo/gems/faker-0.9.5/lib/faker/company.rb:35:in
block
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.
from faker.
I'm having the same problem as lgrains.
from faker.
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.
from faker.
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)
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin10.7.0]
from faker.
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.
from faker.
Same issue here: private method `rand' called for "translation missing: pt-BR.faker.address.street_address":ActiveSupport::SafeBuffer
Whats the fix?
from faker.
@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!
from faker.
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!
from faker.
@rubiety, thanks for the tip - I have pushed this change. if you and @maca could try it out and let me know if it works for you, I'll push a new gem.
Thanks!
from faker.
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.
from faker.
It actually works for rspec but not for cucumber
my env.rb:
require 'cucumber/rails'
require 'faker'
I18n.reload!
Dir[Rails.root.join("test/factories/**/*.rb")].each {|f| require f}
...
from faker.
Had to switch back to 0.3.1 and ignore deprecation warnings for #returning
from faker.
I still have this issue.
from faker.
@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:
private method `rand' called for "translation missing: en.faker.name.first_name"
and your tip worked like a charm!
require 'factory_girl'
require 'faker'
I18n.reload! # <== Thanks @rubiety
I also had to do this in environment.rb:
config.i18n.default_locale = :en
or you can do this:
config.i18n.locale = :en
from faker.
Still have this issue. It appears on Jenkins builds.
I18n.reload! not helps
https://gist.github.com/1041713
Rails 2.3.8
Ruby 1.8.7 p334 (RVM)
Feel free to ask additional info
from faker.
Pulling the gem from github after commit 22a9476 fixed it for me (Rails 3.1 and Ruby 1.9.2). Thanks!
from faker.
I'm switch to ffaker gem =)
from faker.
I am also setting in config/application.rb
config.i18n.locale = :de
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
from faker.
Setting :en for me was not an option and switching to ffaker worked out well, if someone else still has this issue...
from faker.
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::Name.firstname
, but the actual method is Faker::Name.first_name
. Take care of snake-case in method names!
from faker.
Related Issues (20)
- Trying to call Faker::Music::Opera.saint_saens fails HOT 1
- Some generators have inconsistent names HOT 3
- Dota - Flaky specs
- New generator request: Faker::Commerce.rating HOT 2
- Use deterministic helper to execute the test provided in the block successive number of times HOT 9
- Improve testing of locales files HOT 2
- New generator request: Faker::Company.indian_gst_number HOT 3
- Outdated country names and inconsistencies in en/address.yml HOT 5
- Add benchmarking to faker-ruby HOT 6
- Deprecate Generators with External Calls HOT 3
- Fix/Deprecate `FmaBrotherhood` Generator HOT 2
- Reproducing "Faker::Base#regexify does not work with non-capturing groups or + repeat operator" on v 3.2.1 HOT 2
- `Faker::Time.backward (.forward)` may generate time which is greater (less) than the current time HOT 4
- Fix flaky spec on `TestFakerFile#test_file_name` HOT 6
- Translation missing | en.faker.company.indian_gst_number HOT 6
- Consistent addresses HOT 3
- Drop support for Ruby 2.7 HOT 8
- Invalid GB phone number from `Faker::PhoneNumber.phone_number` HOT 3
- Fake Zip Codes HOT 6
- v3.2.3 correct? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faker.