Sha256: 95445247cf5df78b8cf23dd9c6118510685865ec122bac0cad1424d4aaf4d569
Contents?: true
Size: 1.73 KB
Versions: 2
Compression:
Stored size: 1.73 KB
Contents
require 'spec_helper' describe Ziptz do describe 'when inspected' do let(:ziptz) { Ziptz.new } it 'does not show internal instance variables' do expect(ziptz.inspect).to match /#<Ziptz:\d+>/ end end describe '#time_zone_name' do let(:ziptz) { Ziptz.new } 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 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_uses_dst?' do let(:ziptz) { Ziptz.new } 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 end describe '#time_zone_offset' do let(:ziptz) { Ziptz.new } 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 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 describe '#zips' do context 'when given a time zone' do let(:ziptz) { Ziptz.new } it 'returns an array of zip codes' do expect(ziptz.zips('Pacific/Pago_Pago')).to eq %w(96799) end 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 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ziptz-2.0.1 | spec/ziptz_spec.rb |
ziptz-2.0.0 | spec/ziptz_spec.rb |