5 require File.join(File.dirname(__FILE__), '../../../../config/environment')
8 class MockSuccess < Net::HTTPSuccess #:nodoc: all
13 class MockFailure < Net::HTTPServiceUnavailable #:nodoc: all
18 # Base class for testing geocoders.
19 class BaseGeocoderTest < Test::Unit::TestCase #:nodoc: all
21 # Defines common test fixtures.
23 @address = 'San Francisco, CA'
24 @full_address = '100 Spear St, San Francisco, CA, 94105-1522, US'
25 @full_address_short_zip = '100 Spear St, San Francisco, CA, 94105, US'
27 @success = GeoKit::GeoLoc.new({:city=>"SAN FRANCISCO", :state=>"CA", :country_code=>"US", :lat=>37.7742, :lng=>-122.417068})
28 @success.success = true
31 def test_timeout_call_web_service
32 GeoKit::Geocoders::Geocoder.class_eval do
37 url = "http://www.anything.com"
38 GeoKit::Geocoders::timeout = 1
39 assert_nil GeoKit::Geocoders::Geocoder.call_geocoder_service(url)
42 def test_successful_call_web_service
43 url = "http://www.anything.com"
44 GeoKit::Geocoders::Geocoder.expects(:do_get).with(url).returns("SUCCESS")
45 assert_equal "SUCCESS", GeoKit::Geocoders::Geocoder.call_geocoder_service(url)
48 def test_find_geocoder_methods
49 public_methods = GeoKit::Geocoders::Geocoder.public_methods
50 assert public_methods.include?("yahoo_geocoder")
51 assert public_methods.include?("google_geocoder")
52 assert public_methods.include?("ca_geocoder")
53 assert public_methods.include?("us_geocoder")
54 assert public_methods.include?("multi_geocoder")
55 assert public_methods.include?("ip_geocoder")