diff --git a/test/test_helper.rb b/test/test_helper.rb index d0b6ca48924b90bcc0b67381fc4e5b40a376bd8c..00055c80748ca686fd5277c83bff2f6fbf189cc9 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -120,7 +120,9 @@ module Geocoder fixture_exists?(filename) ? filename : default_fixture_filename end - alias_method :make_api_http_request, :make_api_request + # This alias allows us to use this method in further tests + # to actually test http requests + alias_method :actual_make_api_request, :make_api_request remove_method(:make_api_request) def make_api_request(query) diff --git a/test/unit/lookup_test.rb b/test/unit/lookup_test.rb index c4dbce1364cb7ed4fa5c36c511d990e1c6c648d8..5a91ad573596da1fbf2a8acda5b3772ff882a721 100644 --- a/test/unit/lookup_test.rb +++ b/test/unit/lookup_test.rb @@ -160,19 +160,4 @@ class LookupTest < GeocoderTestCase assert_equal :google, Geocoder::Lookup::Google.new.handle assert_equal :geocoder_ca, Geocoder::Lookup::GeocoderCa.new.handle end - - def test_http_request - Geocoder.configure(use_https: true) - - require 'webmock/test_unit' - WebMock.enable! - stub_all = WebMock.stub_request(:any, /.*/).to_return(status: 200) - - g = Geocoder::Lookup::Google.new - g.send(:make_api_http_request, Geocoder::Query.new('test location')) - assert_requested(stub_all) - - WebMock.reset! - WebMock.disable! - end end diff --git a/test/unit/lookups/google_test.rb b/test/unit/lookups/google_test.rb index 490b863d523ed1c777413f4f885127fbb0de9029..32f147e978268248b81d08758c08bc83d85e043a 100644 --- a/test/unit/lookups/google_test.rb +++ b/test/unit/lookups/google_test.rb @@ -111,4 +111,19 @@ class GoogleTest < GeocoderTestCase query = Geocoder::Query.new("Madison Square Garden, New York, NY") assert_match(/^https:/, query.url) end + + def test_actual_make_api_request_with_https + Geocoder.configure(use_https: true, lookup: :google) + + require 'webmock/test_unit' + WebMock.enable! + stub_all = WebMock.stub_request(:any, /.*/).to_return(status: 200) + + g = Geocoder::Lookup::Google.new + g.send(:actual_make_api_request, Geocoder::Query.new('test location')) + assert_requested(stub_all) + + WebMock.reset! + WebMock.disable! + end end