spec/ziptz_spec.rb in ziptz-2.0.17 vs spec/ziptz_spec.rb in ziptz-2.1.0
- old
+ new
@@ -27,19 +27,31 @@
expect(ziptz.time_zone_name('xyz')).to be_nil
end
end
end
- describe '#time_zone_uses_dst?' do
+ describe '#time_zone_name' do
context 'when given a 5-digit zipcode' do
it 'returns the time zone number' do
expect(ziptz.time_zone_name('97034')).to eq 'America/Los_Angeles'
end
end
+
+ context 'when given a 9-digit zipcode' do
+ it 'returns the time zone number' do
+ expect(ziptz.time_zone_name('97034-1234')).to eq 'America/Los_Angeles'
+ end
+ end
+
+ context 'when there is no matching zipcode' do
+ it 'returns nil' do
+ expect(ziptz.time_zone_name('xyz')).to be_nil
+ end
+ end
end
- describe '#time_zone_offset' do
+ describe '#time_zone_uses_dst?' do
context 'when given a 5-digit zipcode' do
it 'returns a boolean' do
expect(ziptz.time_zone_uses_dst?('97034')).to eq true
expect(ziptz.time_zone_uses_dst?('85004')).to eq false
end
@@ -52,10 +64,30 @@
end
end
context 'when there is no matching zipcode' do
it 'returns nil' do
+ expect(ziptz.time_zone_uses_dst?('xyz')).to be_nil
+ end
+ end
+ end
+
+ describe '#time_zone_offset' do
+ context 'when given a 5-digit zipcode' do
+ it 'returns the time zone number' do
+ expect(ziptz.time_zone_offset('97034')).to eq(-8)
+ end
+ end
+
+ context 'when given a 9-digit zipcode' do
+ it 'returns the time zone number' do
+ expect(ziptz.time_zone_offset('97034-1234')).to eq(-8)
+ end
+ end
+
+ context 'when there is no matching zipcode' do
+ it 'returns nil' do
expect(ziptz.time_zone_offset('xyz')).to be_nil
end
end
end
@@ -67,11 +99,11 @@
it 'is case-insensitive' do
expect(ziptz.zips('pacific/pago_pago')).to eq %w[96799]
end
- it 'returns nil for unknown time zones' do
- expect(ziptz.zips('Glark')).to be_nil
+ it 'returns empty array for unknown time zones' do
+ expect(ziptz.zips('Glark')).to be_empty
end
end
end
end