You need to sign in or sign up before continuing.
Newer
Older
$: << File.join(File.dirname(__FILE__), "..", "..")
class MaxmindTest < GeocoderTestCase
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
def setup
Geocoder.configure(ip_lookup: :maxmind)
end
def test_maxmind_result_on_ip_address_search
Geocoder.configure(maxmind: {service: :city_isp_org})
result = Geocoder.search("74.200.247.59").first
assert result.is_a?(Geocoder::Result::Maxmind)
end
def test_maxmind_result_knows_country_service_name
Geocoder.configure(maxmind: {service: :country})
assert_equal :country, Geocoder.search("24.24.24.21").first.service_name
end
def test_maxmind_result_knows_city_service_name
Geocoder.configure(maxmind: {service: :city})
assert_equal :city, Geocoder.search("24.24.24.22").first.service_name
end
def test_maxmind_result_knows_city_isp_org_service_name
Geocoder.configure(maxmind: {service: :city_isp_org})
assert_equal :city_isp_org, Geocoder.search("24.24.24.23").first.service_name
end
def test_maxmind_result_knows_omni_service_name
Geocoder.configure(maxmind: {service: :omni})
assert_equal :omni, Geocoder.search("24.24.24.24").first.service_name
end
def test_maxmind_special_result_components
Geocoder.configure(maxmind: {service: :omni})
result = Geocoder.search("24.24.24.24").first
assert_equal "Road Runner", result.isp_name
assert_equal "Cable/DSL", result.netspeed
assert_equal "rr.com", result.domain
end
def test_maxmind_raises_exception_when_service_not_configured
Geocoder.configure(maxmind: {service: nil})
assert_raises Geocoder::ConfigurationError do
Geocoder::Query.new("24.24.24.24").url
end
end
def test_maxmind_works_when_loopback_address_on_omni
Geocoder.configure(maxmind: {service: :omni})
result = Geocoder.search("127.0.0.1").first
assert_equal "", result.country_code
end
def test_maxmind_works_when_loopback_address_on_country
Geocoder.configure(maxmind: {service: :country})
result = Geocoder.search("127.0.0.1").first
assert_equal "", result.country_code
end
end