Skip to content
Snippets Groups Projects
Commit 84fe70e5 authored by Daniel Norman's avatar Daniel Norman
Browse files

Add street accessors to Google result

parent 6bd4b594
No related branches found
No related tags found
No related merge requests found
......@@ -59,6 +59,16 @@ module Geocoder::Result
end
end
def street_number
if street_number = address_components_of_type(:street_number).first
street_number['long_name']
end
end
def street_address
[street_number, route].compact.join(' ')
end
def types
@data['types']
end
......
......@@ -17,6 +17,12 @@ class ServicesTest < Test::Unit::TestCase
result.address_components_of_type(:route).first['long_name']
end
def test_google_result_components_contains_street_number
result = Geocoder.search("Madison Square Garden, New York, NY").first
assert_equal "4",
result.address_components_of_type(:street_number).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
......@@ -27,6 +33,11 @@ class ServicesTest < Test::Unit::TestCase
assert_equal nil, result.city
end
def test_google_street_address_returns_formatted_street_address
result = Geocoder.search("Madison Square Garden, New York, NY").first
assert_equal "4 Penn Plaza", result.street_address
end
def test_google_precision
result = Geocoder.search("Madison Square Garden, New York, NY").first
assert_equal "ROOFTOP",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment