Sha256: 1761090a316c20bc86268d321839f57abbcce0a34293140e21624f36bbd79d8b

Contents?: true

Size: 1.28 KB

Versions: 7

Compression:

Stored size: 1.28 KB

Contents

require 'spec_helper'

describe Ziptz do
  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 'Pacific'
      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
    let(:ziptz) { Ziptz.new }

    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 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('American Samoa')).to eq %w(96799 96941 96942 96943 96944)
      end

      it 'is case-insensitive' do
        expect(ziptz.zips('american samoa')).to eq %w(96799 96941 96942 96943 96944)
      end

      it 'returns nil for unknown time zones' do
        expect(ziptz.zips('Glark')).to be_nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ziptz-1.0.7 spec/ziptz_spec.rb
ziptz-1.0.6 spec/ziptz_spec.rb
ziptz-1.0.5 spec/ziptz_spec.rb
ziptz-1.0.4 spec/ziptz_spec.rb
ziptz-1.0.3 spec/ziptz_spec.rb
ziptz-1.0.1 spec/ziptz_spec.rb
ziptz-1.0.0 spec/ziptz_spec.rb