X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/baf9ff0ec39c13f52ee8d4f087641dc5fcc9c53b..fcc68b4dc198b7cb0cf93467d96038b0844675fe:/vendor/plugins/geokit/test/ca_geocoder_test.rb diff --git a/vendor/plugins/geokit/test/ca_geocoder_test.rb b/vendor/plugins/geokit/test/ca_geocoder_test.rb new file mode 100644 index 0000000..9d797ce --- /dev/null +++ b/vendor/plugins/geokit/test/ca_geocoder_test.rb @@ -0,0 +1,41 @@ +require File.join(File.dirname(__FILE__), 'base_geocoder_test') + +GeoKit::Geocoders::geocoder_ca = "SOMEKEYVALUE" + +class CaGeocoderTest < BaseGeocoderTest #:nodoc: all + + CA_SUCCESS=<<-EOF + + 49.243086-123.153684 + EOF + + def setup + @ca_full_hash = {:street_address=>"2105 West 32nd Avenue",:city=>"Vancouver", :state=>"BC"} + @ca_full_loc = GeoKit::GeoLoc.new(@ca_full_hash) + end + + def test_geocoder_with_geo_loc_with_account + response = MockSuccess.new + response.expects(:body).returns(CA_SUCCESS) + url = "http://geocoder.ca/?stno=2105&addresst=West+32nd+Avenue&city=Vancouver&prov=BC&auth=SOMEKEYVALUE&geoit=xml" + GeoKit::Geocoders::CaGeocoder.expects(:call_geocoder_service).with(url).returns(response) + verify(GeoKit::Geocoders::CaGeocoder.geocode(@ca_full_loc)) + end + + def test_service_unavailable + response = MockFailure.new + #Net::HTTP.expects(:get_response).with(URI.parse("http://geocoder.ca/?stno=2105&addresst=West+32nd+Avenue&city=Vancouver&prov=BC&auth=SOMEKEYVALUE&geoit=xml")).returns(response) + url = "http://geocoder.ca/?stno=2105&addresst=West+32nd+Avenue&city=Vancouver&prov=BC&auth=SOMEKEYVALUE&geoit=xml" + GeoKit::Geocoders::CaGeocoder.expects(:call_geocoder_service).with(url).returns(response) + assert !GeoKit::Geocoders::CaGeocoder.geocode(@ca_full_loc).success + end + + private + + def verify(location) + assert_equal "BC", location.state + assert_equal "Vancouver", location.city + assert_equal "49.243086,-123.153684", location.ll + assert !location.is_us? + end +end \ No newline at end of file