1 require File.join(File.dirname(__FILE__), 'base_geocoder_test')
3 GeoKit::Geocoders::provider_order=[:google,:yahoo,:us]
5 class MultiGeocoderTest < BaseGeocoderTest #:nodoc: all
9 @failure = GeoKit::GeoLoc.new
12 def test_successful_first
13 GeoKit::Geocoders::GoogleGeocoder.expects(:geocode).with(@address).returns(@success)
14 assert_equal @success, GeoKit::Geocoders::MultiGeocoder.geocode(@address)
18 GeoKit::Geocoders::GoogleGeocoder.expects(:geocode).with(@address).returns(@failure)
19 GeoKit::Geocoders::YahooGeocoder.expects(:geocode).with(@address).returns(@success)
20 assert_equal @success, GeoKit::Geocoders::MultiGeocoder.geocode(@address)
23 def test_double_failover
24 GeoKit::Geocoders::GoogleGeocoder.expects(:geocode).with(@address).returns(@failure)
25 GeoKit::Geocoders::YahooGeocoder.expects(:geocode).with(@address).returns(@failure)
26 GeoKit::Geocoders::UsGeocoder.expects(:geocode).with(@address).returns(@success)
27 assert_equal @success, GeoKit::Geocoders::MultiGeocoder.geocode(@address)
31 GeoKit::Geocoders::GoogleGeocoder.expects(:geocode).with(@address).returns(@failure)
32 GeoKit::Geocoders::YahooGeocoder.expects(:geocode).with(@address).returns(@failure)
33 GeoKit::Geocoders::UsGeocoder.expects(:geocode).with(@address).returns(@failure)
34 assert_equal @failure, GeoKit::Geocoders::MultiGeocoder.geocode(@address)
37 def test_invalid_provider
38 temp = GeoKit::Geocoders::provider_order
39 GeoKit::Geocoders.provider_order = [:bogus]
40 assert_equal @failure, GeoKit::Geocoders::MultiGeocoder.geocode(@address)
41 GeoKit::Geocoders.provider_order = temp