From 43482629def737dc5ce2d835ececd5d50ffd22ed Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Wed, 7 Nov 2012 19:43:01 -0500 Subject: [PATCH] Use fake API key for testing Google Premier. Also move API key config to separate method. --- test/services_test.rb | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/test/services_test.rb b/test/services_test.rb index 1dbe8b16..2e6cd3af 100644 --- a/test/services_test.rb +++ b/test/services_test.rb @@ -6,17 +6,8 @@ class ServicesTest < Test::Unit::TestCase def test_query_url_contains_values_in_params_hash Geocoder::Lookup.all_services_except_test.each do |l| - next if l == :google_premier # TODO: need to set keys to test next if l == :freegeoip # does not use query string - # need to set API key for Yahoo for OAuth encoding - if l == :yahoo - Geocoder::Configuration.api_key = [ - 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', - 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' - ] - else - Geocoder::Configuration.api_key = nil - end + set_api_key!(l) url = Geocoder::Lookup.get(l).send(:query_url, Geocoder::Query.new( "test", :params => {:one_in_the_hand => "two in the bush"} )) @@ -194,4 +185,23 @@ class ServicesTest < Test::Unit::TestCase assert_equal "46 West 31st Street, New York, NY, 10001, US", result.address end + + private # ------------------------------------------------------------------ + + def set_api_key!(lookup_name) + if lookup_name == :google_premier + Geocoder::Configuration.api_key = [ + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb', + 'cccccccccccccccccccccccccccccc' + ] + elsif lookup_name == :yahoo + Geocoder::Configuration.api_key = [ + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb' + ] + else + Geocoder::Configuration.api_key = nil + end + end end -- GitLab