Sha256: 264b3ff960c95a79ece9c6409b046f28713703a2c92b2818c6948cf6f6ac8228
Contents?: true
Size: 1.36 KB
Versions: 6
Compression:
Stored size: 1.36 KB
Contents
require 'spec/helper' describe Location do it "should parse city" do test_location("san francisco", "san francisco", nil, nil) end it "should parse city state abbreviation" do test_location("san francisco ca", "san francisco", "CA", nil) end it "should parse city state full" do test_location("san francisco california", "san francisco", "CA", nil) end it "should parse city comma state" do test_location("san francisco, ca", "san francisco", "CA", nil) end it "should parse city state zip" do test_location("san francisco ca 94114-1212", "san francisco", "CA", '94114-1212') end it "should parse city comma state zip" do test_location("san francisco, ca 94114-1212", "san francisco", "CA", '94114-1212') end it "should parse city zip" do test_location("san francisco 94114-1212", "san francisco", nil, '94114-1212') end it "should parse state zip" do test_location("ca 94114-1212", nil, "CA", '94114-1212') end it "should parse state" do test_location("california", nil, "CA", nil) end it "should parse zip" do test_location("94114-1212", nil, nil, '94114-1212') end private def test_location(str, city, state, zip) l = Location.new(str) l.city.should == city if l.city l.state.to_s(:abbr).should == state.upcase if l.state l.zip.to_s.should == zip if l.zip end end
Version data entries
6 entries across 6 versions & 2 rubygems