Skip to content
Snippets Groups Projects
Commit 755c6c5b authored by Andrew Kane's avatar Andrew Kane
Browse files

Added tests

parent 373eac54
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@ module Geocoder::Result
def address
parts =
if international_endpoint?
(1..4).map { |i| @data["address#{i}"] }
(1..12).map { |i| @data["address#{i}"] }
else
[
delivery_line_1,
......@@ -64,7 +64,7 @@ module Geocoder::Result
def street
international_endpoint? ?
@data['address1'] :
components['thoroughfare_name'] :
components['street_name']
end
......
[
{
"address1": "13 Rue Yves Toudic",
"address2": "10E Arrondissement",
"address3": "75010 Paris",
"components": {
"super_administrative_area": "Ile-De-France",
"administrative_area": "Paris",
"country_iso_3": "FRA",
"locality": "Paris",
"dependent_locality": "10E Arrondissement",
"postal_code": "75010",
"postal_code_short": "75010",
"premise": "13",
"premise_number": "13",
"thoroughfare": "Rue Yves Toudic",
"thoroughfare_name": "Yves Toudic",
"thoroughfare_type": "Rue"
},
"metadata": {
"latitude": 48.870131,
"longitude": 2.363473,
"geocode_precision": "Premise",
"max_geocode_precision": "DeliveryPoint",
"address_format": "premise thoroughfare|dependent_locality|postal_code locality"
},
"analysis": {
"verification_status": "Verified",
"address_precision": "Premise",
"max_address_precision": "DeliveryPoint"
}
}
]
......@@ -29,6 +29,11 @@ class SmartyStreetsTest < GeocoderTestCase
assert_match(/us-zipcode\.api\.smartystreets\.com\/lookup\?/, query.url)
end
def test_query_for_international_geocode
query = Geocoder::Query.new("13 rue yves toudic 75010", country: "France")
assert_match(/international-street\.api\.smartystreets\.com\/verify\?/, query.url)
end
def test_smarty_streets_result_components
result = Geocoder.search("Madison Square Garden, New York, NY").first
assert_equal "Penn", result.street
......@@ -36,6 +41,7 @@ class SmartyStreetsTest < GeocoderTestCase
assert_equal "1703", result.zip4
assert_equal "New York", result.city
assert_equal "36061", result.fips
assert_equal "US", result.country_code
assert !result.zipcode_endpoint?
end
......@@ -44,9 +50,19 @@ class SmartyStreetsTest < GeocoderTestCase
assert_equal "Brooklyn", result.city
assert_equal "New York", result.state
assert_equal "NY", result.state_code
assert_equal "US", result.country_code
assert result.zipcode_endpoint?
end
def test_smarty_streets_result_components_with_international_query
result = Geocoder.search("13 rue yves toudic 75010", country: "France").first
assert_equal 'Yves Toudic', result.street
assert_equal 'Paris', result.city
assert_equal '75010', result.postal_code
assert_equal 'FRA', result.country_code
assert result.international_endpoint?
end
def test_smarty_streets_when_longitude_latitude_does_not_exist
result = Geocoder.search("96628").first
assert_equal nil, result.coordinates
......
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