Sha256: 747ab95460c5cd3c257a4a23f3a6c2edb8690790d5207e707f685693da14c8ee

Contents?: true

Size: 1.77 KB

Versions: 1

Compression:

Stored size: 1.77 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "ZipCodeInfo" do
  
  describe "Positive Test Cases: " do
  
    it "should find the right city" do 
      zip = ZipCodeInfo.instance.scf_city_for "99100"
      zip.should eql "Spokane"
    end
  
    it "should find the right state" do 
      zip = ZipCodeInfo.instance.state_for "99100"
      zip.should eql "WA"
    end
    
    it "should find the right city when the zip is an integer" do 
      zip = ZipCodeInfo.instance.scf_city_for 60699
      ZipCodeInfo.instance.code.should eql "60699"
      zip.should eql "Chicago"
    end
  
    it "should find the right state when the zip is an integer" do 
      zip = ZipCodeInfo.instance.state_for 60699
      ZipCodeInfo.instance.code.should eql "60699"
      zip.should eql "IL"
    end
    
    it "should find the right city name when the city name contains an &" do 
      zip = ZipCodeInfo.instance.scf_city_for "11099"
      zip.should eql "Queens &West Nassau"
    end
  
  end
  
  describe "Negative Test Cases: " do
  
    it "should handle no zip code" do 
      zip = ZipCodeInfo.instance.scf_city_for
      zip.should be_false
    end

    it "should handle an invalid zip code that has a valid format - 00000" do
      zip = ZipCodeInfo.instance.scf_city_for("00000")
      zip.should be_false
    end
  
    it "should handle an invalid zip code - too long" do 
      zip = ZipCodeInfo.instance.scf_city_for("123456")
      zip.should be_false
    end
  
    it "should handle an invalid zip code - too short" do 
      zip = ZipCodeInfo.instance.scf_city_for "1234"
      zip.should be_false
    end
  
    it "should handle an invalid zip code - alphanum" do 
      zip = ZipCodeInfo.instance.scf_city_for "1a23g"
      zip.should be_false 
    end

  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zip-code-info-0.1.1 spec/zip-code-info_spec.rb