Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion test/test_address.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def test_country_parse
[ "Philadelphia 19131", "Philadelphia", "", "19131" ],
[ "Pennsylvania 19131", "Pennsylvania", "PA", "19131" ], # kind of a misfeature
[ "19131", "", "", "19131" ],
[ "19131-9999", "", "", "19131" ],
[ "19131-9999", "", "", "19131" ]
].each do |fixture|
fixture_name = fixture[0].gsub(/(?:\s+|[,])/,'_')
define_method "test_city_parse_#{fixture_name}" do
Expand All @@ -146,6 +146,27 @@ def check_city(fixture)
end
end

# test city parsing from text
[
{ :text => "590 Tonne Rd Elk Grove Village, IL 60007",
:city => "Elk Grove Village"},
{ :text => "1600 Pennsylvania Av., Washington DC 20050",
:city => "Washington"},
{ :text => "1005 Gravenstein Highway North, Sebastopol CA",
:city => "Sebastopol"}
].each do |fixture|
define_method "test_city_parse_from_#{fixture[:text].gsub(/(?:\s+|[.,])/,'_').downcase}" do
pend if fixture[:pending]
test_parse_of_city(fixture)
end
end

def test_parse_of_city(fixture)
text = fixture[:text]
city = fixture[:city]
assert Address.new(text).city.include?(city.downcase)
end

# test address parsing code
[
{:text => "1600 Pennsylvania Av., Washington DC 20050",
Expand Down