test/test_google_geocode.rb in google-geocode-1.0.0 vs test/test_google_geocode.rb in google-geocode-1.1.0
- old
+ new
@@ -42,18 +42,70 @@
assert_equal 'invalid key', e.message
else
flunk 'Error expected'
end
- def test_locate_bad_address
+ def test_locate_missing_address
URI::HTTP.responses << <<-EOF.strip
+<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.0"><Response><name>1600</name><Status><code>601</code><request>geocode</request></Status></Response></kml>
+ EOF
+
+ @gg.locate 'x'
+
+ rescue GoogleGeocode::AddressError => e
+ assert_equal 'missing address', e.message
+ else
+ flunk 'Error expected'
+ end
+
+ def test_locate_server_error
+ URI::HTTP.responses << <<-EOF.strip
+<?xml version='1.0' encoding='UTF-8'?><kml xmlns='http://earth.google.com/kml/2.0'><Response><name>1600 Amphitheater Pkwy, Mountain View, CA</name><Status><code>500</code><request>geocode</request></Status></Response></kml>
+ EOF
+
+ @gg.locate 'x'
+
+ rescue GoogleGeocode::Error => e
+ assert_equal 'server error', e.message
+ else
+ flunk 'Error expected'
+ end
+
+ def test_locate_too_many_queries
+ URI::HTTP.responses << <<-EOF.strip
+<?xml version='1.0' encoding='UTF-8'?><kml xmlns='http://earth.google.com/kml/2.0'><Response><name>1600 Amphitheater Pkwy, Mountain View, CA</name><Status><code>620</code><request>geocode</request></Status></Response></kml>
+ EOF
+
+ @gg.locate 'x'
+
+ rescue GoogleGeocode::KeyError => e
+ assert_equal 'too many queries', e.message
+ else
+ flunk 'Error expected'
+ end
+
+ def test_locate_unavailable_address
+ URI::HTTP.responses << <<-EOF.strip
+<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.0"><Response><name>42-44 Hanway Street, London</name><Status><code>603</code><request>geocode</request></Status></Response></kml>
+ EOF
+
+ @gg.locate 'x'
+
+ rescue GoogleGeocode::AddressError => e
+ assert_equal 'unavailable address', e.message
+ else
+ flunk 'Error expected'
+ end
+
+ def test_locate_unknown_address
+ URI::HTTP.responses << <<-EOF.strip
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.0"><Response><name>1600</name><Status><code>602</code><request>geocode</request></Status></Response></kml>
EOF
@gg.locate 'x'
rescue GoogleGeocode::AddressError => e
- assert_equal 'invalid address', e.message
+ assert_equal 'unknown address', e.message
else
flunk 'Error expected'
end
end