Skip to content
Snippets Groups Projects
Commit 49140748 authored by David's avatar David
Browse files

Added more tests for Telize lookup

parent 34c1a99f
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,41 @@ require 'test_helper'
class TelizeTest < GeocoderTestCase
def setup
Geocoder.configure(ip_lookup: :telize)
Geocoder.configure(ip_lookup: :telize, telize: {host: nil})
end
def test_query_url
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{^https://telize-v1\.p\.mashape\.com/location/74\.200\.247\.59}, lookup.query_url(query)
end
def test_includes_api_key_when_set
Geocoder.configure(api_key: "api_key")
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{/location/74\.200\.247\.59\?mashape-key=api_key}, lookup.query_url(query)
end
def test_uses_custom_host_when_set
Geocoder.configure(telize: {host: "example.com"})
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{^http://example\.com/location/74\.200\.247\.59$}, lookup.query_url(query)
end
def test_allows_https_when_custom_host
Geocoder.configure(use_https: true, telize: {host: "example.com"})
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{^https://example\.com}, lookup.query_url(query)
end
def test_requires_https_when_not_custom_host
Geocoder.configure(use_https: false)
lookup = Geocoder::Lookup::Telize.new
query = Geocoder::Query.new("74.200.247.59")
assert_match %r{^https://telize-v1\.p\.mashape\.com}, lookup.query_url(query)
end
def test_result_on_ip_address_search
......@@ -15,6 +49,8 @@ class TelizeTest < GeocoderTestCase
def test_result_components
result = Geocoder.search("74.200.247.59").first
assert_equal "Jersey City, NJ 07302, United States", result.address
assert_equal "US", result.country_code
assert_equal [40.7209, -74.0468], result.coordinates
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