Sha256: cbda6bd1dc0270db92c9fa76122c9995072aba3465411d42353be121d672a257
Contents?: true
Size: 1.13 KB
Versions: 6
Compression:
Stored size: 1.13 KB
Contents
# encoding: UTF-8 require 'test_helper' module Graticule module Geocoder class GeocoderUsTest < Test::Unit::TestCase def setup URI::HTTP.responses = [] URI::HTTP.uris = [] @geocoder = GeocoderUs.new @location = Location.new( :street => "1600 Pennsylvania Ave NW, Washington DC 20502", :longitude => -77.037684, :latitude => 38.898748 ) end def test_success prepare_response(:success) assert_equal @location, @geocoder.locate('1600 Pennsylvania Ave, Washington DC') end def test_url prepare_response(:success) @geocoder.locate('1600 Pennsylvania Ave, Washington DC') assert_equal 'http://rpc.geocoder.us/service/rest/geocode?address=1600%20Pennsylvania%20Ave,%20Washington%20DC', URI::HTTP.uris.first end def test_locate_bad_address prepare_response(:unknown) assert_raises(AddressError) { @geocoder.locate('yuck') } end protected def prepare_response(id) URI::HTTP.responses << response('geocoder_us', id) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems