From 808fce399362e46993a7be5479fbfec8549c5161 Mon Sep 17 00:00:00 2001 From: Darren Holland Date: Thu, 20 Jun 2013 12:53:57 -0500 Subject: [PATCH] test for parsing city from text --- test/test_address.rb | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test_address.rb b/test/test_address.rb index 0b771cd..a8f3ce4 100644 --- a/test/test_address.rb +++ b/test/test_address.rb @@ -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 @@ -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",