Sha256: 6c574c971ec20a368342213d80e51a6147d0ab99187a4d393e61a8a628e289ba

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require_relative 'spec_helper'

describe 'ZipCodeInfo' do

  describe '#scf_city_for' do

    it 'allows zip code as string' do
      city = ZipCodeInfo.instance.scf_city_for '99100'
      expect(city).to eql 'Spokane'
    end

    it 'allows zip code as integer' do
      city = ZipCodeInfo.instance.scf_city_for 99100
      expect(city).to eql 'Spokane'
    end


    it 'handles city names with &' do
      city = ZipCodeInfo.instance.scf_city_for '11099'
      expect(city).to eql 'Queens &West Nassau'
    end

    it 'handles extended zip codes' do
      city = ZipCodeInfo.instance.scf_city_for '99100-1234'
      expect(city).to eql 'Spokane'
    end

    it 'returns false if zip code is missing' do
      city = ZipCodeInfo.instance.scf_city_for
      expect(city).to be false
    end

    it 'returns false if zip code not found' do
      city = ZipCodeInfo.instance.scf_city_for '00000'
      expect(city).to be false
    end

    it 'returns false if zip code is invalid' do
      city = ZipCodeInfo.instance.scf_city_for('123456')
      expect(city).to be false
    end
  end

  describe '#state_for' do

    it 'allows zip code as string' do
      state = ZipCodeInfo.instance.state_for '60699'
      expect(state).to eql 'IL'
    end

    it 'allows zip code as integer' do
      state = ZipCodeInfo.instance.state_for 60699
      expect(state).to eql 'IL'
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zip-code-info-0.2.1 spec/zip-code-info_spec.rb
zip-code-info-0.2.0 spec/zip-code-info_spec.rb