Skip to content

Commit

Permalink
All tests pass except for some tests that do not seem recorded by VCR.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryankopf committed Jan 24, 2023
1 parent c5cc25c commit 271b672
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 14 deletions.
4 changes: 2 additions & 2 deletions geokit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
2 changes: 1 addition & 1 deletion lib/geokit/geocoders/bing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion lib/geokit/geocoders/yahoo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
8 changes: 4 additions & 4 deletions test/test_bing_geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/test_opencage_geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions test/test_yandex_geocoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 271b672

Please sign in to comment.