diff --git a/lib/geocoder/results/google.rb b/lib/geocoder/results/google.rb index 73e2289db58c0027b006f28d4520107e753e10b1..e293c0ba12b6bea6683ec43ec7a7ff0af3c6f956 100644 --- a/lib/geocoder/results/google.rb +++ b/lib/geocoder/results/google.rb @@ -53,6 +53,12 @@ module Geocoder::Result end end + def route + if route = address_components_of_type(:route).first + route['long_name'] + end + end + def types @data['types'] end diff --git a/test/services_test.rb b/test/services_test.rb index 540f71c3f4ab1f2d4540f09dfcc3a83a2e6d35b3..0000b57be0f2e7e5f75e9a63d59c86caf92230a7 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -25,6 +25,12 @@ class ServicesTest < Test::Unit::TestCase result.address_components_of_type(:sublocality).first['long_name'] end + def test_google_result_components_contains_route + result = Geocoder.search("Madison Square Garden, New York, NY").first + assert_equal "Penn Plaza", + result.address_components_of_type(:route).first['long_name'] + end + def test_google_returns_city_when_no_locality_in_result result = Geocoder.search("no locality").first assert_equal "Haram", result.city