diff --git a/lib/geocoder/lookups/yahoo.rb b/lib/geocoder/lookups/yahoo.rb index adbe2e98afc2b1e213a402f325e098a0a402daba..b4cd2dbd5e38df7adc9062992b48c562204b7abc 100644 --- a/lib/geocoder/lookups/yahoo.rb +++ b/lib/geocoder/lookups/yahoo.rb @@ -21,7 +21,7 @@ module Geocoder::Lookup return [] end else - warn "Yahoo Geocoding API error: #{doc['responsecode']}." + warn "Yahoo Geocoding API error: #{doc['responsecode']} (#{doc['reason']})." return [] end end diff --git a/test/fixtures/yahoo_error.json b/test/fixtures/yahoo_error.json new file mode 100644 index 0000000000000000000000000000000000000000..7dbfdfeabeaa611d00af6ef756118795619703a1 --- /dev/null +++ b/test/fixtures/yahoo_error.json @@ -0,0 +1 @@ +{"bossresponse":{"responsecode":"6000","reason":"internal error"}} diff --git a/test/services_test.rb b/test/services_test.rb index 9d204aacb9c667fbb110d913a832f71d054056b4..19898d699a8b38946628879bce76fba1e22ce0cf 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -82,6 +82,14 @@ class ServicesTest < Test::Unit::TestCase assert_equal [], Geocoder.search("no results") end + def test_yahoo_error + Geocoder::Configuration.lookup = :yahoo + # keep test output clean: suppress timeout warning + orig = $VERBOSE; $VERBOSE = nil + assert_equal [], Geocoder.search("error") + $VERBOSE = orig + end + def test_yahoo_result_components Geocoder::Configuration.lookup = :yahoo result = Geocoder.search("madison square garden").first diff --git a/test/test_helper.rb b/test/test_helper.rb index 7361b300d8d58b418c762bcbf4fd4cb4b84bc67a..8285233e5411f014a7d53772550403fbe399fbf6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -104,6 +104,7 @@ module Geocoder raise SocketError if query.text == "socket_error" file = case query.text when "no results"; :no_results + when "error"; :error else :madison_square_garden end read_fixture "yahoo_#{file}.json"