Sha256: 67f4feb4112567bf5a300971e032e45740e05431a11a865b8ad95a9d4b42bec2

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

require 'test_helper'

module Graticule
  module Geocoder
    class MapquestTest < Test::Unit::TestCase
      def setup
        URI::HTTP.responses = []
        URI::HTTP.uris = []
        @geocoder = Mapquest.new('client_id', 'password')
      end

      def test_success
        prepare_response(:success)
        location = Location.new(
          :country => "US",
          :latitude => 44.152019,
          :locality => "Lovell",
          :longitude => -70.892706,
          :postal_code => "04051-3919",
          :precision => :address,
          :region => "ME",
          :street => "44 Allen Rd"
        )
        assert_equal(location, @geocoder.locate('44 Allen Rd., Lovell, ME 04051'))
      end

      def test_multi_result
        prepare_response(:multi_result)
        location = Location.new(
          :country => "US",
          :latitude => 40.925598,
          :locality => "Stony Brook",
          :longitude => -73.141403,
          :postal_code => nil,
          :precision => :locality,
          :region => "NY",
          :street => nil
        )
        assert_equal(location, @geocoder.locate('217 Union St., NY'))
      end

      protected
      
      def prepare_response(id)
        URI::HTTP.responses << response('mapquest', id)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
graticule-1.0.0.pre2 test/graticule/geocoder/mapquest_test.rb
graticule-1.0.0.pre test/graticule/geocoder/mapquest_test.rb