diff --git a/test/lookup_test.rb b/test/lookup_test.rb index 6e77e4ba7d0c2b878f129e6748aab46270a2bb5c..6ad02c52330dd7c48f7bc0afd124babb9411f2cc 100644 --- a/test/lookup_test.rb +++ b/test/lookup_test.rb @@ -20,6 +20,30 @@ class LookupTest < Test::Unit::TestCase end end + def test_raises_exception_on_invalid_key + Geocoder.configure(:always_raise => [Geocoder::InvalidApiKey]) + #Geocoder::Lookup.all_services_except_test.each do |l| + [:yahoo, :yandex, :maxmind].each do |l| + lookup = Geocoder::Lookup.get(l) + assert_raises Geocoder::InvalidApiKey do + lookup.send(:results, Geocoder::Query.new("invalid key")) + end + end + end + + def test_warns_about_invalid_key + # keep test output clean: suppress timeout warning + orig = $VERBOSE; $VERBOSE = nil + #Geocoder::Lookup.all_services_except_test.each do |l| + [:yahoo, :yandex, :maxmind].each do |l| + Geocoder.configure(:lookup => l) + set_api_key!(l) + assert_equal [], Geocoder.search("invalid key") + end + ensure + $VERBOSE = orig + end + def test_does_not_choke_on_nil_address Geocoder::Lookup.all_services.each do |l| Geocoder.configure(:lookup => l) diff --git a/test/services_test.rb b/test/services_test.rb index 9c232a8593f3155658a77f3aa70bf023a43c315e..9174c0c687a6641c7afb17851edb617d28039f4e 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -113,35 +113,6 @@ class ServicesTest < Test::Unit::TestCase end end - def test_yahoo_raises_exception_on_invalid_key - Geocoder.configure(:always_raise => [Geocoder::InvalidApiKey]) - l = Geocoder::Lookup.get(:yahoo) - assert_raises Geocoder::InvalidApiKey do - l.send(:results, Geocoder::Query.new("invalid key")) - end - end - - # --- Yandex --- - - def test_yandex_warns_about_invalid_key - # keep test output clean: suppress timeout warning - orig = $VERBOSE; $VERBOSE = nil - Geocoder.configure(:lookup => :yandex) - set_api_key!(:yandex) - assert_equal [], Geocoder.search("invalid key") - ensure - $VERBOSE = orig - end - - def test_yandex_raises_exception_on_invalid_key - Geocoder.configure(:always_raise => [Geocoder::InvalidApiKey]) - l = Geocoder::Lookup.get(:yandex) - assert_raises Geocoder::InvalidApiKey do - l.send(:results, Geocoder::Query.new("invalid key")) - end - end - - # --- Geocoder.ca --- def test_geocoder_ca_result_components @@ -179,16 +150,6 @@ class ServicesTest < Test::Unit::TestCase assert_equal "Plano, TX 75093, US", result.address end - def test_maxmind_raises_exception_on_invalid_key - Geocoder.configure( - :always_raise => [Geocoder::InvalidApiKey] - ) - l = Geocoder::Lookup.get(:maxmind) - assert_raises Geocoder::InvalidApiKey do - l.send(:results, Geocoder::Query.new("invalid key")) - end - end - # --- Bing ---