Skip to content

Commit 8320708

Browse files
authored
Merge pull request #55 from ipinfo/silvano/eng-537-fix-ruby-library-tests-failures
Fix IPinfo tests
2 parents daae18c + 0f98344 commit 8320708

File tree

1 file changed

+62
-64
lines changed

1 file changed

+62
-64
lines changed

test/ipinfo_test.rb

Lines changed: 62 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -9,64 +9,55 @@ class IPinfoTest < Minitest::Test
99
def assert_ip6(resp)
1010
assert_equal(resp.ip, TEST_IPV6)
1111
assert_equal(resp.ip_address, IPAddr.new(TEST_IPV6))
12-
assert_equal(resp.city, 'Osaka')
13-
assert_equal(resp.region, 'Osaka')
12+
refute_nil(resp.city)
13+
refute_nil(resp.region)
1414
assert_equal(resp.country, 'JP')
1515
assert_equal(resp.country_name, 'Japan')
1616
assert_equal(resp.is_eu, false)
17-
assert_equal(resp.loc, '34.6938,135.5011')
18-
assert_equal(resp.latitude, '34.6938')
19-
assert_equal(resp.longitude, '135.5011')
20-
assert_equal(resp.postal, '543-0062')
17+
refute_nil(resp.loc)
18+
refute_nil(resp.latitude)
19+
refute_nil(resp.longitude)
20+
refute_nil(resp.postal)
2121
assert_equal(resp.timezone, 'Asia/Tokyo')
2222
assert_equal(resp.country_flag_url, 'https://cdn.ipinfo.io/static/images/countries-flags/JP.svg')
23-
assert_equal(
24-
resp.asn,
25-
{
26-
"asn": 'AS2497',
27-
"name": 'Internet Initiative Japan Inc.',
28-
"domain": 'iij.ad.jp',
29-
"route": '2001:240::/32',
30-
"type": 'isp'
31-
}
32-
)
33-
# This test is flaky, with the domain flapping between iij.net and iij.ad.jp
34-
#
35-
# assert_equal(
36-
# resp.company,
37-
# {
38-
# "name": 'IIJ Internet',
39-
# "domain": 'iij.net',
40-
# "type": 'isp'
41-
# }
42-
# )
23+
refute_nil(resp.asn)
24+
assert_equal(resp.asn[:asn], 'AS2497')
25+
assert_equal(resp.asn[:name], 'Internet Initiative Japan Inc.')
26+
refute_nil(resp.asn[:domain])
27+
assert_equal(resp.asn[:route], '2001:240::/32')
28+
assert_equal(resp.asn[:type], 'isp')
29+
refute_nil(resp.company)
30+
refute_nil(resp.company[:name])
31+
refute_nil(resp.company[:domain])
32+
assert_equal(resp.company[:type], "isp")
4333
assert_equal(
4434
resp.privacy,
4535
{
46-
"vpn": false,
47-
"proxy": false,
48-
"tor": false,
49-
"relay": false,
50-
"hosting": false,
51-
"service": ''
36+
vpn: false,
37+
proxy: false,
38+
tor: false,
39+
relay: false,
40+
hosting: false,
41+
service: ''
5242
}
5343
)
5444
assert_equal(
5545
resp.abuse,
5646
{
57-
"address": 'Brisbane, Australia',
58-
"country": 'AU',
59-
"email": '[email protected]',
60-
"name": 'ABUSE APNICAP',
61-
"network": '2001:200::/23',
62-
"phone": '+000000000'
47+
address: 'Brisbane, Australia',
48+
country: 'AU',
49+
50+
name: 'ABUSE APNICAP',
51+
network: '2001:200::/23',
52+
phone: '+000000000'
6353
}
6454
)
6555
assert_equal(
6656
resp.domains,
6757
{
68-
"total": 0,
69-
"domains": []
58+
page: 0,
59+
total: 0,
60+
domains: []
7061
}
7162
)
7263
end
@@ -88,50 +79,57 @@ def assert_ip4(resp)
8879
assert_equal(resp.country_currency['symbol'], '$')
8980
assert_equal(resp.continent['code'], 'NA')
9081
assert_equal(resp.continent['name'], 'North America')
91-
assert_equal(resp.loc, '38.0088,-122.1175')
92-
assert_equal(resp.latitude, '38.0088')
93-
assert_equal(resp.longitude, '-122.1175')
82+
refute_nil(resp.loc)
83+
refute_nil(resp.latitude)
84+
refute_nil(resp.longitude)
9485
assert_equal(resp.postal, '94043')
9586
assert_equal(resp.timezone, 'America/Los_Angeles')
9687
assert_equal(
9788
resp.asn,
9889
{
99-
"asn": 'AS15169',
100-
"name": 'Google LLC',
101-
"domain": 'google.com',
102-
"route": '8.8.8.0/24',
103-
"type": 'hosting'
90+
asn: 'AS15169',
91+
name: 'Google LLC',
92+
domain: 'google.com',
93+
route: '8.8.8.0/24',
94+
type: 'hosting'
10495
}
10596
)
10697
assert_equal(
10798
resp.company,
10899
{
109-
"name": 'Google LLC',
110-
"domain": 'google.com',
111-
"type": 'hosting'
100+
name: 'Google LLC',
101+
domain: 'google.com',
102+
type: 'hosting',
103+
firmographic: {
104+
name: 'Google LLC',
105+
domain: 'google.com',
106+
founded: '2002-10-22',
107+
employees: nil,
108+
sic: 5734
109+
}
112110
}
113111
)
114112
assert_equal(
115113
resp.privacy,
116114
{
117-
"vpn": false,
118-
"proxy": false,
119-
"tor": false,
120-
"relay": false,
121-
"hosting": true,
122-
"service": ''
115+
vpn: false,
116+
proxy: false,
117+
tor: false,
118+
relay: false,
119+
hosting: true,
120+
service: ''
123121
}
124122
)
125123
assert_equal(
126124
resp.abuse,
127125
{
128-
"address": 'US, CA, Mountain View, ' \
129-
'1600 Amphitheatre Parkway, 94043',
130-
"country": 'US',
131-
"email": '[email protected]',
132-
"name": 'Abuse',
133-
"network": '8.8.8.0/24',
134-
"phone": '+1-650-253-0000'
126+
address: 'US, CA, Mountain View, ' \
127+
'1600 Amphitheatre Parkway, 94043',
128+
country: 'US',
129+
130+
name: 'Abuse',
131+
network: '8.8.8.0/24',
132+
phone: '+1-650-253-0000'
135133
}
136134
)
137135
assert_equal(resp.domains[:ip], TEST_IPV4)

0 commit comments

Comments
 (0)