test/test_google_geocoder.rb in geokit-1.13.1 vs test/test_google_geocoder.rb in geokit-1.14.0
- old
+ new
@@ -116,10 +116,11 @@
url = "#{@base_url}?sensor=false&address=#{escape(@address)}"
TestHelper.expects(:last_url).with(url)
res = geocode(@address, :google_city)
assert_nil res.street_address
assert_equal 'CA', res.state
+ assert_equal 'San Francisco County', res.county
assert_equal 'San Francisco', res.city
assert_equal '37.7749295,-122.4194155', res.ll
assert res.is_us?
assert_equal 'San Francisco, CA, USA', res.full_address
assert_equal 'city', res.precision
@@ -131,10 +132,11 @@
url = "#{@base_url}?sensor=false&address=#{escape(@address)}"
TestHelper.expects(:last_url).with(url)
res = geocode(@address, :google_sublocality)
assert_equal '682 Prospect Place', res.street_address
assert_equal 'NY', res.state
+ assert_equal 'Kings County', res.county
assert_equal 'Brooklyn', res.city
assert_equal '40.6745812,-73.9541582', res.ll
assert res.is_us?
assert_equal '682 Prospect Place, Brooklyn, NY 11216, USA', res.full_address
assert_equal 'address', res.precision
@@ -146,10 +148,11 @@
url = "#{@base_url}?sensor=false&address=#{escape(@address)}"
TestHelper.expects(:last_url).with(url)
res = geocode(@address, :google_administrative_area_level_3)
assert_equal '8 Barkwood Lane', res.street_address
assert_equal 'NY', res.state
+ assert_equal 'Saratoga County', res.county
assert_equal 'Clifton Park', res.city
assert_equal '42.829583,-73.788174', res.ll
assert res.is_us?
assert_equal '8 Barkwood Lane, Clifton Park, NY 12065, USA', res.full_address
assert_equal 'building', res.precision
@@ -173,10 +176,11 @@
def test_google_city_with_geo_loc
url = "#{@base_url}?sensor=false&address=#{escape(@address)}"
TestHelper.expects(:last_url).with(url)
res = geocode(@google_city_loc, :google_city)
assert_equal 'CA', res.state
+ assert_equal 'San Francisco County', res.county
assert_equal 'San Francisco', res.city
assert_equal '37.7749295,-122.4194155', res.ll
assert res.is_us?
assert_equal 'San Francisco, CA, USA', res.full_address
assert_nil res.street_address
@@ -259,10 +263,11 @@
assert_equal madrid.lng.to_s.slice(1..5), res.lng.to_s.slice(1..5)
assert_equal 'ES', res.country_code
assert_equal 'google', res.provider
assert_equal 'Madrid', res.city
+ assert_equal 'Madrid', res.county
assert_equal 'Community of Madrid', res.state
assert_equal 'Spain', res.country
assert_equal '28013', res.zip
assert_equal true, res.success
@@ -351,11 +356,11 @@
filtered_result = geocode('austin', :test_component_filtering_off)
assert_equal 'TX', filtered_result.state
assert_equal 'Austin, TX, USA', filtered_result.full_address
- url = 'https://maps.google.com/maps/api/geocode/json?sensor=false&address=austin&components=administrative_area:il%7Ccountry:us'
+ url = "https://maps.google.com/maps/api/geocode/json?sensor=false&address=austin&components=administrative_area%3Ail%7Ccountry%3Aus"
TestHelper.expects(:last_url).with(url)
filtered_result = geocode('austin',
:test_component_filtering_on,
components: { administrative_area: 'IL', country: 'US' })
@@ -366,7 +371,16 @@
TestHelper.expects(:last_url).with(url)
filtered_result = geocode('austin', :test_component_filtering_on_without_filter, components: nil)
assert_equal 'TX', filtered_result.state
assert_equal 'Austin, TX, USA', filtered_result.full_address
+
+ url = "https://maps.google.com/maps/api/geocode/json?sensor=false&address=S%C3%A3o+Paulo&components=administrative_area%3As%C3%A3o+paulo%7Ccountry%3Abr"
+ TestHelper.expects(:last_url).with(url)
+ filtered_result = geocode("São Paulo",
+ :test_component_filtering_with_special_characters,
+ components: { administrative_area: "São Paulo", country: "BR" })
+
+ assert_equal "SP", filtered_result.state
+ assert_equal "São Paulo, State of São Paulo, Brazil", filtered_result.full_address
end
end