Skip to content
Snippets Groups Projects
Commit 58652a89 authored by Tony Amoyal's avatar Tony Amoyal
Browse files

added street_address attribute for geocodio, updated fixture and outdated attribute tests

parent d090662d
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,10 @@ module Geocoder::Result
address_components["suffix"]
end
def street_address
[number, address_components["formatted_street"]].compact.join(' ')
end
def state
address_components["state"]
end
......
{"input":{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC"},"results":[{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC, 20004","location":{"lat":"38.895019","lng":"-77.028095"},"accuracy":1},{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","city":"Washington","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington DC, 20004","location":{"lat":"38.895016122449","lng":"-77.028084377551"},"accuracy":0.8}]}
\ No newline at end of file
{"input":{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","formatted_street":"Pennsylvania Ave NW","city":"Washington","state":"DC"},"formatted_address":"1101 Pennsylvania Ave NW, Washington, DC"},"results":[{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","formatted_street":"Pennsylvania Ave NW","city":"Washington","county":"District of Columbia","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington, DC 20004","location":{"lat":38.895019,"lng":-77.028095},"accuracy":1,"accuracy_type":"range_interpolation"},{"address_components":{"number":"1101","street":"Pennsylvania","suffix":"Ave","postdirectional":"NW","formatted_street":"Pennsylvania Ave NW","city":"Washington","county":"District of Columbia","state":"DC","zip":"20004"},"formatted_address":"1101 Pennsylvania Ave NW, Washington, DC 20004","location":{"lat":38.895016122449,"lng":-77.028084377551},"accuracy":0.8,"accuracy_type":"range_interpolation"}]}
\ No newline at end of file
......@@ -13,13 +13,14 @@ class GeocodioTest < GeocoderTestCase
result = Geocoder.search("1101 Pennsylvania Ave NW, Washington DC").first
assert_equal 1.0, result.accuracy
assert_equal "1101", result.number
assert_equal "1101 Pennsylvania Ave NW", result.street_address
assert_equal "Ave", result.suffix
assert_equal "DC", result.state
assert_equal "20004", result.zip
assert_equal "NW", result.postdirectional
assert_equal "Washington", result.city
assert_equal "1101 Pennsylvania Ave NW, Washington DC, 20004", result.formatted_address
assert_equal({ "lat" => "38.895019", "lng" => "-77.028095" }, result.location)
assert_equal "1101 Pennsylvania Ave NW, Washington, DC 20004", result.formatted_address
assert_equal({ "lat" => 38.895019, "lng" => -77.028095 }, result.location)
end
def test_no_results
......
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