Sha256: 6e9ea80db1f7c076e3afff4b645689897648cc8c9c2f6c8e4ceb22a7e1c782e8
Contents?: true
Size: 1.58 KB
Versions: 5
Compression:
Stored size: 1.58 KB
Contents
require File.dirname(__FILE__) + '/../../../test_helper' module Graticule module Geocoder class YahooTest < Test::Unit::TestCase def setup URI::HTTP.responses = [] URI::HTTP.uris = [] @geocoder = Yahoo.new 'APP_ID' @location = Location.new( :street => "701 1st Ave", :locality => "Sunnyvale", :region => "CA", :postal_code => "94089-1019", :country => "US", :longitude => -122.025078, :latitude => 37.416402, :precision => Precision.address ) end def test_locate prepare_response(:success) assert_equal @location, @geocoder.locate('701 First Street, Sunnyvale, CA') end def test_locate_with_first prepare_response(:success) assert_equal @location, @geocoder.locate(:first, '701 First Street, Sunnyvale, CA') end def test_locate_with_all prepare_response(:multiple) assert_equal 4, @geocoder.locate(:all, 'Gardiner').size end def test_url prepare_response(:success) @geocoder.locate('701 First Street, Sunnyvale, CA') assert_equal 'http://api.local.yahoo.com/MapsService/V1/geocode?appid=APP_ID&location=701+First+Street%2C+Sunnyvale%2C+CA&output=xml', URI::HTTP.uris.first end def test_locate_bad_address prepare_response(:unknown_address) assert_raise(Error) { @geocoder.locate('yucksthoeusthaoeusnhtaosu') } end protected def prepare_response(id) URI::HTTP.responses << response('yahoo', id) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems