Module: Geo::Etest

Defined in:
lib/geo/etest.rb

Instance Method Summary collapse

Instance Method Details

#test_geoip_citiesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/geo/etest.rb', line 44

def test_geoip_cities
  berlins = Geo.cities("Berlin")
  assert berlins.length > 1
  assert_equal berlins.first, {
           :area_code => nil,
           :city_name => "Berlin",
            :dma_code => nil,
        :country_code => "EU.DE",
       :country_code2 => "DE",
       :country_code3 => "DEU",
        :country_name => "Germany",
      :continent_code => "EU",
                  :ip => "",
            :latitude => 52.516699999999986,
           :longitude => 13.400000000000006,
                :name => "Berlin, Germany",
         :postal_code => "",
             :request => "",
         :region_code => "EU.DE",
         :region_name => "16",
            :timezone => "Europe/Berlin"
  }
end

#test_geoip_cities_callbackObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/geo/etest.rb', line 68

def test_geoip_cities_callback
  r = nil
  Geo.cities do |rec|
    r = rec
    break
  end
  
  assert_equal r, :area_code => nil,
   :city_name => "",
   :continent_code => "AS",
   :country_code => "AS.JP",
   :country_code2 => "JP",
   :country_code3 => "JPN",
   :country_name => "Japan",
   :dma_code => nil,
   :ip => "",
   :latitude => 36.0,
   :longitude => 138.0,
   :name => "Japan",
   :postal_code => "",
   :region_code => "AS.JP",
   :region_name => "",
   :request => "",
   :timezone => "Asia/Tokyo"
end

#test_geoip_googleObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/geo/etest.rb', line 2

def test_geoip_google
  assert_equal Geo.city("8.8.8.8"),
             :request => "8.8.8.8",
                  :ip => "8.8.8.8",
       :country_code2 => "US",
       :country_code3 => "USA",
        :country_name => "United States",
      :continent_code => "NA",
         :region_name => "CA",
           :city_name => "Mountain View",
         :postal_code => "",
            :latitude => 37.385999999999996,
           :longitude => -122.0838,
            :dma_code => 807,
           :area_code => 650,
            :timezone => "America/Los_Angeles",
                :name => "Mountain View, CA, United States",
         :region_code => "NA.US.CA",
        :country_code => "NA.US"
end

#test_geoip_heiseObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/geo/etest.rb', line 23

def test_geoip_heise
  assert_equal Geo.city("127.0.0.1"),
             :request => "193.99.144.85",
                  :ip => "193.99.144.85",
       :country_code2 => "DE",
       :country_code3 => "DEU",
        :country_name => "Germany",
      :continent_code => "EU",
         :region_name => "06",
           :city_name => "Hanover",
         :postal_code => "",
            :latitude => 52.36670000000001,
           :longitude => 9.716700000000003,
            :dma_code => nil,
           :area_code => nil,
            :timezone => "Europe/Berlin",
                :name => "Hanover, Germany",
         :region_code => "EU.DE",
        :country_code => "EU.DE"
end