Sha256: 2b9eca12c278ef3d15b8f9d84d411d603a7fe2f67e00756d849ac6c04b4b69ad
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
require "spec_helper" require "traco/locale_fallbacks" describe Traco::LocaleFallbacks do describe ".new" do it "raises ArgumentError if an unknown argument passed in" do expect { Traco::LocaleFallbacks.new(:foo) }.to raise_error(ArgumentError) expect { Traco::LocaleFallbacks.new(nil) }.to raise_error(ArgumentError) end end describe "#[]" do context "with the ':default' option" do it "returns given locale, then default locale" do I18n.default_locale = :en subject = Traco::LocaleFallbacks.new(:default) expect(subject[:sv]).to eq [ :sv, :en ] end end context "with the ':any' option" do it "returns given locale, then default locale, then remaining available locales alphabetically" do I18n.default_locale = :en I18n.available_locales = [ :en, :sv, :uk, :de ] subject = Traco::LocaleFallbacks.new(:any) expect(subject[:sv]).to eq [ :sv, :en, :de, :uk ] end end context "with the 'false' option" do it "returns only given locale" do subject = Traco::LocaleFallbacks.new(false) expect(subject[:sv]).to eq [ :sv ] end end context "with an explicit list of locales" do it "returns only those locales" do subject = Traco::LocaleFallbacks.new([ :en ]) expect(subject[:sv]).to eq [ :en ] end end context "with the ':default_first' option" do it "returns default locale, then remaining available locales alphabetically" do I18n.default_locale = :uk I18n.available_locales = [ :en, :sv, :uk, :de ] subject = Traco::LocaleFallbacks.new(:default_first) expect(subject[:sv]).to eq [ :uk, :de, :en, :sv ] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
traco-3.2.0 | spec/locale_fallbacks_spec.rb |