spec/csl/locale_spec.rb in csl-1.3.2 vs spec/csl/locale_spec.rb in csl-1.4.0
- old
+ new
@@ -46,16 +46,16 @@
end
describe '.new' do
it { is_expected.not_to be_nil }
- it 'defaults to default language' do
- expect(Locale.new.language).to eq(Locale.default.split(/-/)[0].to_sym)
+ it 'has no language' do
+ expect(Locale.new.language).to be_nil
end
- it 'defaults to default region' do
- expect(Locale.new.region).to eq(Locale.default.split(/-/)[1].to_sym)
+ it 'has no region' do
+ expect(Locale.new.region).to be_nil
end
it 'contains no dates by default' do
expect(Locale.new.dates).to be_nil
end
@@ -85,10 +85,16 @@
end
end
+ describe '.parse' do
+ it 'does not set a default language' do
+ expect(Locale.parse('<locale/>').language).to be_nil
+ end
+ end
+
describe '#set' do
it 'when passed "en-GB" sets language to :en and region to :GB' do
locale.set('en-GB')
expect([locale.language, locale.region]).to eq([:en, :GB])
@@ -145,9 +151,32 @@
end
it 'creates duplicate date elements if the first locale has no options' do
locale.merge!(Locale.load('en-US'))
expect(locale).to have_dates
+ end
+ end
+
+ describe 'terms' do
+ let(:us) { Locale.load('en-US') }
+
+ it 'does not change the terms if none are set on either locale' do
+ expect { locale.merge!(Locale.new) }.not_to change { locale.terms.to_s }
+ end
+
+ it 'overrides terms with those of the other locale' do
+ expect(locale).not_to have_terms
+
+ locale.merge! us
+ expect(locale).to have_terms
+ end
+
+ it 'makes copies of the terms' do
+ locale.merge! us
+ expect(locale).to have_terms
+
+ expect(locale.terms.first).to eq(us.terms.first)
+ expect(locale.terms.first).not_to be(us.terms.first)
end
end
end
describe '#legacy?' do