spec/data_spec.rb in countries-2.0.8 vs spec/data_spec.rb in countries-2.1.0
- old
+ new
@@ -94,10 +94,14 @@
describe 'hotloading existing data' do
before do
ISO3166::Data.register(
alpha2: 'TW',
name: 'NEW Taiwan',
+ subdivisions: {
+ CHA: {name: 'New Changhua'},
+ CYI: {name: 'New Municipality'}
+ },
translations: {
'en' => 'NEW Taiwan',
'de' => 'NEW Taiwan'
}
)
@@ -110,18 +114,24 @@
ISO3166.configuration.locales = [:es, :de, :de]
expect(data['name']).to eq 'NEW Taiwan'
expect(subject.name).to eq 'NEW Taiwan'
expect(subject.translations).to eq('en' => 'NEW Taiwan',
'de' => 'NEW Taiwan')
+ expect(subject.subdivisions).to eq(CHA: ISO3166::Subdivision.new({name: 'New Changhua'}),
+ CYI: ISO3166::Subdivision.new({name: 'New Municipality'}))
end
end
describe 'hotloading data' do
before do
ISO3166::Data.register(
alpha2: 'LOL',
name: 'Happy Country',
+ subdivisions: {
+ LOL1: {name: 'Happy sub1'},
+ LOL2: {name: 'Happy sub2'}
+ },
translations: {
'en' => 'Happy Country',
'de' => 'glückliches Land'
}
)
@@ -131,9 +141,11 @@
it 'can be done' do
data = ISO3166::Data.new('LOL').call
expect(data['name']).to eq 'Happy Country'
expect(subject.name).to eq 'Happy Country'
+ expect(subject.subdivisions).to eq(LOL1: ISO3166::Subdivision.new({name: 'Happy sub1'}),
+ LOL2: ISO3166::Subdivision.new({name: 'Happy sub2'}))
end
it 'detect a stale cache' do
ISO3166::Data.register(alpha2: 'SAD', name: 'Sad Country')
data = ISO3166::Data.new('SAD').call