Skip to content
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

Setting locale (FR) does not change country #208

Closed
belgoros opened this issue May 27, 2014 · 4 comments
Closed

Setting locale (FR) does not change country #208

belgoros opened this issue May 27, 2014 · 4 comments

Comments

@belgoros
Copy link

I tried to set up a locale as suggested:

Faker::Config.locale = :fr

I tried to do that in 2 different ways:

  • by putting it in spec_helper config block:
require 'faker'
...

RSpec.configure do |config|
...
Faker::Config.locale = :fr
...
end
  • by putting it directly in a spec example file (clients_controller_spec.rb):
require 'spec_helper'
require 'faker'

describe ClientsController do
  before { Faker::Config.locale = :fr }
...
end

In both cases the country value was NOT correct:

  • CONGO
  • SENEGAL
  • BARBADOS
  • EQUATORIAL GUINEA

etc.

The only solution I found was to set a country as follows in my Factory file:

factory :client do
...
  country    { Faker::Address.default_country }
....
end

Is it a right way ?
Any idea ?

Thank you.

Produced with faker version 1.3.0, Ruby 2.0.0, Windows XP box.

@ridget
Copy link

ridget commented May 29, 2014

@javix Faker::Address.country returns a random country from the list found in https://github.com/stympy/faker/blob/master/lib/locales/en.yml , the default country will always return the locale country as set by https://github.com/stympy/faker/blob/master/lib/locales/fr.yml or https://github.com/stympy/faker/blob/master/lib/locales/en-au.yml

Assuming you were expecting Faker::Address.country to return France of course :)

@belgoros
Copy link
Author

OK, seeing that cities, phones were for France, I believed that setting a locale would also send the appropriate values for all the methods (country, phone, city, first_name, last_name, etc.). I didn't investigate all the generated phones numbers and cities, but I had a strong idea that all of them were French. Can you confirm that ALL the values are generated randomly, no matter which locale is set? If so, why set up a locale in this case ? Thank you.

@ridget
Copy link

ridget commented May 29, 2014

@javix as far as im aware it only gets overridden by whats actually in https://github.com/stympy/faker/blob/master/lib/locales/fr.yml for the French locale. Any other questions might be best posed at the gem authors, I just came in here to see if there was a pull request I could submit :)

@belgoros
Copy link
Author

OK, got it, I'll close the issue as it does not seem to be a bug. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants