Sha256: 10336e96778e675d7dd0661e10498e5e3bce0e73607d9b5a68ae807a39decbed

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

require 'spec/helper'

describe ZipCode do
  it "should parse base" do
    zip = ZipCode.parse '30306'
    zip.base.should == '30306'
    zip.plus_four.should == nil
  end

  it "should parse plus four" do
    zip = ZipCode.parse '30306-3522'
    zip.base.should == '30306'
    zip.plus_four.should == '3522'
  end

  it "should throw exception on unsupported parse format" do
    lambda { ZipCode.parse('303065344') }.should raise_error
  end

  it "should format :base" do 
    ZipCode.parse('30306-3522').to_s(:base).should == '30306'
  end

  it "should format :plus_four" do 
    ZipCode.parse('30306-3522').to_s(:plus_four).should == '30306-3522'
  end

  it "should throw exception on unsupported to_s format" do
    lambda { ZipCode.parse('30306-3522').to_s(:bogus) }.should raise_error
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dburkes-people_places_things-1.2.0 spec/zip_code_spec.rb
dburkes-people_places_things-1.3.0 spec/zip_code_spec.rb