Sha256: e9bbcf544282cb45e69c0beaffd897b5ff2bbe096684b07ec43560cb0d82d247
Contents?: true
Size: 1.48 KB
Versions: 6
Compression:
Stored size: 1.48 KB
Contents
# encoding: UTF-8 require 'test_helper' module Graticule module Geocoder class MultimapTest < Test::Unit::TestCase def setup URI::HTTP.responses = [] URI::HTTP.uris = [] @geocoder = Multimap.new 'API_KEY' @location = Location.new( :street => "Oxford Street", :locality => "LONDON", :postal_code => "W1", :country => "GB", :longitude => -0.14839, :latitude => 51.51452, :precision => :address ) end def test_locate prepare_response(:success) assert_equal @location, @geocoder.locate('Oxford Street, LONDON, W1') end def test_url_from_string prepare_response(:success) @geocoder.locate('Oxford Street, LONDON, W1') assert_equal 'http://clients.multimap.com/API/geocode/1.2/API_KEY?qs=Oxford%20Street,%20LONDON,%20W1', URI::HTTP.uris.first end def test_url_from_location prepare_response(:success) @geocoder.locate(:street => 'Oxford Street', :locality => 'London') assert_equal 'http://clients.multimap.com/API/geocode/1.2/API_KEY?city=London&countryCode=&postalCode=®ion=&street=Oxford%20Street', URI::HTTP.uris.first end def test_locate_bad_address prepare_response(:no_matches) assert_raise(Error) { @geocoder.locate('yucksthoeusthaoeusnhtaosu') } end protected def prepare_response(id) URI::HTTP.responses << response('multimap', id) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems