diff --git a/geokit.gemspec b/geokit.gemspec index 106078e8..48bab8ec 100644 --- a/geokit.gemspec +++ b/geokit.gemspec @@ -21,7 +21,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 1.9.3' + spec.required_ruby_version = '>= 2.5.9' spec.add_development_dependency 'bundler', '>= 1.0' spec.add_development_dependency 'coveralls' spec.add_development_dependency 'mocha' @@ -34,5 +34,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'typhoeus' # used in net_adapter spec.add_development_dependency 'vcr' # webmock 2 not yet compatible out of the box with VCR - spec.add_development_dependency 'webmock', '< 2' # used in vcr + spec.add_development_dependency 'webmock'#, '< 2' # used in vcr end diff --git a/lib/geokit/geocoders/bing.rb b/lib/geokit/geocoders/bing.rb index 59089b42..eb26b249 100644 --- a/lib/geokit/geocoders/bing.rb +++ b/lib/geokit/geocoders/bing.rb @@ -21,7 +21,7 @@ def self.submit_url(address) culture = options && options[:culture] culture_string = culture ? "&c=#{culture}" : '' address_str = address.is_a?(GeoLoc) ? address.to_geocodeable_s : address - "#{protocol}://dev.virtualearth.net/REST/v1/Locations/#{URI.escape(address_str)}?key=#{key}#{culture_string}&o=xml" + "#{protocol}://dev.virtualearth.net/REST/v1/Locations/#{CGI.escape(address_str)}?key=#{key}#{culture_string}&o=xml" end def self.parse_xml(xml) diff --git a/lib/geokit/geocoders/yahoo.rb b/lib/geokit/geocoders/yahoo.rb index eded4c78..cd425d53 100644 --- a/lib/geokit/geocoders/yahoo.rb +++ b/lib/geokit/geocoders/yahoo.rb @@ -113,7 +113,10 @@ def nonce def percent_encode(string) # ref http://snippets.dzone.com/posts/show/1260 - URI.escape(string, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")).gsub('*', '%2A') + # puts string + # puts "---------\n\n\n\n" + # (URI::Parser.new).escape(string, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")).gsub('*', '%2A') + CGI.escape(string) end # @ref http://oauth.net/core/1.0/#rfc.section.9.2 diff --git a/test/helper.rb b/test/helper.rb index c01d6f1b..df46e3e1 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -13,11 +13,12 @@ require 'coverage_loader' require 'vcr_loader' require 'test/unit' -require 'mocha/setup' +require 'mocha/test_unit' require 'net/http' require File.join(File.dirname(__FILE__), '../lib/geokit.rb') + class MockSuccess < Net::HTTPSuccess #:nodoc: all def initialize @header = {} diff --git a/test/test_bing_geocoder.rb b/test/test_bing_geocoder.rb index e3436c07..52ca62eb 100644 --- a/test/test_bing_geocoder.rb +++ b/test/test_bing_geocoder.rb @@ -14,7 +14,7 @@ def assert_url(expected_url) # the testing methods themselves def test_bing_full_address key = geocoder_class.key - url = "#{@base_url}/#{URI.escape(@full_address)}?key=#{key}&o=xml" + url = "#{@base_url}/#{CGI.escape(@full_address)}?key=#{key}&o=xml" res = geocode(@full_address, :bing_full) assert_equal 'CA', res.state assert_equal 'San Francisco', res.city @@ -28,7 +28,7 @@ def test_bing_full_address def test_bing_full_address_au address = '440 King William Street, Adelaide, Australia' key = geocoder_class.key - url = "#{@base_url}/#{URI.escape(address)}?key=#{key}&o=xml" + url = "#{@base_url}/#{CGI.escape(address)}?key=#{key}&o=xml" res = geocode(address, :bing_full_au) assert_equal 'SA', res.state assert_equal 'Adelaide', res.city @@ -43,7 +43,7 @@ def test_bing_full_address_au def test_bing_full_address_de address = 'Platz der Republik 1, 11011 Berlin, Germany' key = geocoder_class.key - url = "#{@base_url}/#{URI.escape(address)}?key=#{key}&o=xml" + url = "#{@base_url}/#{CGI.escape(address)}?key=#{key}&o=xml" res = geocode(address, :bing_full_de) assert_equal 'BE', res.state assert_equal 'Berlin', res.city @@ -59,7 +59,7 @@ def test_bing_full_address_de def test_bing_country address = 'Australia' key = geocoder_class.key - url = "#{@base_url}/#{URI.escape(address)}?key=#{key}&o=xml" + url = "#{@base_url}/#{CGI.escape(address)}?key=#{key}&o=xml" res = geocode(address, :bing_au) assert_equal nil, res.state assert_equal nil, res.city diff --git a/test/test_opencage_geocoder.rb b/test/test_opencage_geocoder.rb index 39053de6..98ea16df 100644 --- a/test/test_opencage_geocoder.rb +++ b/test/test_opencage_geocoder.rb @@ -89,8 +89,8 @@ def test_opencage_reverse2 assert_equal 10, res.precision assert_equal true, res.success - assert_equal 'Прилепски Бранители, Prilep, Pelagonia Region, MK', res.full_address - assert_equal 'Прилепски Бранители', res.street_address + assert_equal 'Прилепски бранители, Prilep, Pelagonia Region, MK', res.full_address + assert_equal 'Прилепски бранители', res.street_address end def test_opencage_cerdanyola diff --git a/test/test_yandex_geocoder.rb b/test/test_yandex_geocoder.rb index a736bb12..94019ebe 100644 --- a/test/test_yandex_geocoder.rb +++ b/test/test_yandex_geocoder.rb @@ -34,7 +34,7 @@ def test_yandex_full_address res = geocode(@full_address) assert_equal 'yandex', res.provider - assert_equal "улица Новый Арбат, 24", res.street_address + assert_equal "Улица новый арбат, 24", res.street_address assert_equal "Москва", res.city assert_equal 55.753083, res.lat assert_equal 37.587614, res.lng @@ -51,8 +51,8 @@ def test_yandex_full_address_with_region_and_district res = geocode(region_address) assert_equal 'yandex', res.provider - assert_equal "улица Станиславского, 21", res.street_address - assert_equal "Ростов на Дону", res.city + assert_equal "Улица станиславского, 21", res.street_address + assert_equal "Ростов на дону", res.city assert_equal "Ростовская область", res.state assert_equal "городской округ Ростов-на-Дону", res.district assert_equal 47.21589, res.lat