1 require File.join(File.dirname(__FILE__), 'base_geocoder_test')
3 GeoKit::Geocoders::geocoder_us = nil
5 class UsGeocoderTest < BaseGeocoderTest #:nodoc: all
7 GEOCODER_US_FULL='37.792528,-122.393981,100 Spear St,San Francisco,CA,94105'
11 @us_full_hash = {:city=>"San Francisco", :state=>"CA"}
12 @us_full_loc = GeoKit::GeoLoc.new(@us_full_hash)
16 response = MockSuccess.new
17 response.expects(:body).returns(GEOCODER_US_FULL)
18 url = "http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}"
19 GeoKit::Geocoders::UsGeocoder.expects(:call_geocoder_service).with(url).returns(response)
20 verify(GeoKit::Geocoders::UsGeocoder.geocode(@address))
23 def test_geocoder_with_geo_loc
24 response = MockSuccess.new
25 response.expects(:body).returns(GEOCODER_US_FULL)
26 url = "http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}"
27 GeoKit::Geocoders::UsGeocoder.expects(:call_geocoder_service).with(url).returns(response)
28 verify(GeoKit::Geocoders::UsGeocoder.geocode(@us_full_loc))
31 def test_service_unavailable
32 response = MockFailure.new
33 url = "http://geocoder.us/service/csv/geocode?address=#{CGI.escape(@address)}"
34 GeoKit::Geocoders::UsGeocoder.expects(:call_geocoder_service).with(url).returns(response)
35 assert !GeoKit::Geocoders::UsGeocoder.geocode(@us_full_loc).success
41 assert_equal "CA", location.state
42 assert_equal "San Francisco", location.city
43 assert_equal "37.792528,-122.393981", location.ll
44 assert location.is_us?
45 assert_equal "100 Spear St, San Francisco, CA, 94105, US", location.full_address #slightly different from yahoo