Sha256: 815ba08469cfea319ef9bb4e24a11ee765416fdd1a662b5271a3f498c3f4a083

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

# encoding: utf-8
require 'spec_helper'

describe 'ISO3166.configuration' do
  it 'has a configuration' do
    expect(ISO3166.configuration).to be_a ISO3166::Configuration
  end

  it 'locales can be changed' do
    ISO3166.configuration.locales = [:es]
    ISO3166.configuration.locales << :de
    expect(ISO3166::Country.new('DE').translation(:de)).to eq 'Deutschland'
    expect(ISO3166::Country.new('DE').translation(:es)).to eq 'Alemania'
    expect(ISO3166::Country.new('DE').translation(:en)).to eq nil
  end

  it 'locales are assumed from I18n.available_locales' do
    I18n.available_locales = [:de, :en]
    ISO3166.reset
    expect(ISO3166::Country.new('DE').translation(:de)).to eq 'Deutschland'
    expect(ISO3166::Country.new('DE').translation(:es)).to eq nil
  end

  it 'locales can be changed' do
    ISO3166.configuration.locales = [:de]
    expect(ISO3166::Country.new('DE').translation(:de)).to eq 'Deutschland'
    expect(ISO3166::Country.new('DE').translation(:es)).to eq nil
  end

  it 'locales can be changed' do
    ISO3166.configuration.locales = [:es, :de, :en]
    expect(ISO3166::Country.new('DE').translation(:es)).to eq 'Alemania'
    expect(ISO3166::Country.new('DE').translation(:en)).to eq 'Germany'
    expect(ISO3166::Country.new('DE').translation(:de)).to eq 'Deutschland'
  end

  it 'locales can be changed with a block' do
    ISO3166.configure do |config|
      config.locales = [:af, :am, :ar, :as, :az, :be, :bg, :bn, :br, :bs, :ca, :cs, :cy, :da, :de, :dz, :el, :en, :eo, :es, :et, :eu, :fa, :fi, :fo, :fr, :ga, :gl, :gu, :he, :hi, :hr, :hu, :hy, :ia, :id, :is, :it, :ja, :ka, :kk, :km, :kn, :ko, :ku, :lt, :lv, :mi, :mk, :ml, :mn, :mr, :ms, :mt, :nb, :ne, :nl, :nn, :oc, :or, :pa, :pl, :ps, :pt, :ro, :ru, :rw, :si, :sk, :sl, :so, :sq, :sr, :sv, :sw, :ta, :te, :th, :ti, :tk, :tl, :tr, :tt, :ug, :uk, :ve, :vi, :wa, :wo, :xh, :zh, :zu]
    end

    expect(ISO3166::Country.new('DE').translations.size).to eq 92

    expect(ISO3166.configuration.loaded_locales.size).to eq 92
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
countries-2.0.0.pre.3 spec/configuration_spec.rb