forked from geokit/geokit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Testing Geokit::Geocoders::useragent, Bing geocode fix with options p…
…aram, reverse_geocode accepts :provider_order param
- Loading branch information
Showing
3 changed files
with
51 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'test/unit' | ||
require 'webmock/test_unit' | ||
|
||
require File.join(File.dirname(__FILE__), '../lib/geokit.rb') | ||
|
||
class UserAgentTest < Test::Unit::TestCase | ||
|
||
NETHTTPDEFAULT = 'Ruby' | ||
NETHTTPDEFAULTHEADERS = {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'} | ||
TYPHOEUSDEFAULT = 'Typhoeus - https://github.com/typhoeus/typhoeus' | ||
TYPHOEUSDEFAULTHEADERS = {'Expect'=>''} | ||
TESTAGENT = 'MyAgent' | ||
URL = 'http://www.example.com' | ||
|
||
def test_nethttp_useragent_set_to_testagent | ||
stub_request(:get, URL).with(:headers => NETHTTPDEFAULTHEADERS.merge('User-Agent' => TESTAGENT)) | ||
|
||
Geokit::Geocoders::useragent = TESTAGENT | ||
Geokit::NetAdapter::NetHttp.do_get(URL) | ||
assert_requested :get, URL | ||
end | ||
|
||
def test_nethttp_useragent_set_to_default | ||
stub_request(:get, URL).with(:headers => NETHTTPDEFAULTHEADERS.merge('User-Agent' => NETHTTPDEFAULT)) | ||
|
||
Geokit::Geocoders::useragent = nil | ||
Geokit::NetAdapter::NetHttp.do_get(URL) | ||
assert_requested :get, URL | ||
end | ||
|
||
def test_typhoeus_set_to_testagent | ||
stub_request(:get, URL).with(:headers => TYPHOEUSDEFAULTHEADERS.merge('User-Agent' => TESTAGENT)) | ||
|
||
Geokit::Geocoders::useragent = TESTAGENT | ||
Geokit::NetAdapter::Typhoeus.do_get(URL) | ||
assert_requested :get, URL | ||
end | ||
|
||
def test_typhoeus_set_to_default | ||
stub_request(:get, URL).with(:headers => TYPHOEUSDEFAULTHEADERS.merge('User-Agent' => TYPHOEUSDEFAULT)) | ||
|
||
Geokit::Geocoders::useragent = nil | ||
Geokit::NetAdapter::Typhoeus.do_get(URL) | ||
assert_requested :get, URL | ||
end | ||
end |