test/test_base_geocoder.rb in geokit-1.2.5 vs test/test_base_geocoder.rb in geokit-1.2.6

- old
+ new

@@ -15,10 +15,16 @@ end # Base class for testing geocoders. class BaseGeocoderTest < Test::Unit::TestCase #:nodoc: all + class Geokit::Geocoders::TestGeocoder < Geokit::Geocoders::Geocoder + def self.do_get(url) + sleep(2) + end + end + # Defines common test fixtures. def setup @address = 'San Francisco, CA' @full_address = '100 Spear St, San Francisco, CA, 94105-1522, US' @full_address_short_zip = '100 Spear St, San Francisco, CA, 94105, US' @@ -26,17 +32,12 @@ @success = Geokit::GeoLoc.new({:city=>"SAN FRANCISCO", :state=>"CA", :country_code=>"US", :lat=>37.7742, :lng=>-122.417068}) @success.success = true end def test_timeout_call_web_service - Geokit::Geocoders::Geocoder.class_eval do - def self.do_get(url) - sleep(2) - end - end url = "http://www.anything.com" Geokit::Geocoders::timeout = 1 - assert_nil Geokit::Geocoders::Geocoder.call_geocoder_service(url) + assert_nil Geokit::Geocoders::TestGeocoder.call_geocoder_service(url) end def test_successful_call_web_service url = "http://www.anything.com" Geokit::Geocoders::Geocoder.expects(:do_get).with(url).returns("SUCCESS")