Sha256: 72b0cd6d6b1472e4c0cae9f85badfc5b413f8f96a5e9af906da1cb7cc0da0766

Contents?: true

Size: 1.11 KB

Versions: 12

Compression:

Stored size: 1.11 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/test_helper.rb')

LoadedEsYaml = ['en', 'es'].inject({}) do |h, locale|
  h[locale] = YAML.load_file(File.expand_path(File.dirname(__FILE__) + "/../lib/locales/#{locale}.yml"))[locale]['faker']
  h
end

class TestEsLocale < Test::Unit::TestCase
  def teardown
    Faker::Config.locale = nil
  end

  def test_locale_separate_from_i18n
    I18n.locale = :en
    Faker::Config.locale = :es
    assert Faker::Address.street_name.match(//)
  end

  def test_configured_locale_translation
    Faker::Config.locale = 'es'
    assert_equal Faker::Base.translate('faker.address.city_prefix').first, LoadedEsYaml['es']['address']['city_prefix'].first
  end

  def test_locale_override_when_calling_translate
    Faker::Config.locale = 'es'
    assert_equal Faker::Base.translate('faker.lorem.words', :locale => :en).first, LoadedEsYaml['en']['lorem']['words'].first
  end

  def test_translation_fallback
    Faker::Config.locale = 'es'
    assert_nil LoadedEsYaml['es']['company']['bs']
    assert_equal Faker::Base.translate('faker.company.bs'), LoadedEsYaml['en']['company']['bs']
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
faker-1.6.3 test/test_es_locale.rb
faker-1.6.2 test/test_es_locale.rb
faker-1.6.1 test/test_es_locale.rb
faker-1.6.0 test/test_es_locale.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/faker-1.5.0/test/test_es_locale.rb
faker-1.5.0 test/test_es_locale.rb
faker-1.4.3 test/test_es_locale.rb
faker-1.4.2 test/test_es_locale.rb
faker-1.4.1 test/test_es_locale.rb
faker-1.4.0 test/test_es_locale.rb
faker-1.3.0 test/test_es_locale.rb
faker-1.2.0 test/test_es_locale.rb