Sha256: 78631f93e90e66775c3dbcbefcb8416ac9d59fcda5f6aad80bb3dde7385e3387
Contents?: true
Size: 1017 Bytes
Versions: 10
Compression:
Stored size: 1017 Bytes
Contents
require File.dirname(__FILE__) + '/../../../test_helper' module Graticule module Geocoder class HostIpTest < Test::Unit::TestCase def setup @geocoder = HostIp.new URI::HTTP.responses = [] URI::HTTP.uris = [] end def test_success prepare_response :success location = Location.new :country => 'US', :locality => 'Mountain View', :region => 'CA', :latitude => 37.402, :longitude => -122.078 assert_equal location, @geocoder.locate('64.233.167.99') end def test_unknown prepare_response :unknown assert_raises(AddressError) { @geocoder.locate('127.0.0.1') } end def test_private_ip prepare_response :private assert_raises(AddressError) { @geocoder.locate('127.0.0.1') } end private def prepare_response(id = :success) URI::HTTP.responses << response('host_ip', id, 'txt') end end end end
Version data entries
10 entries across 10 versions & 3 rubygems