Sha256: 27cba51bfdfe5c2d8bb36b97c174a74ceab24195277a7858330bb5c5e70fdbd7

Contents?: true

Size: 1.39 KB

Versions: 13

Compression:

Stored size: 1.39 KB

Contents

# account code: INDIV30777
# license key: KG39-HM17-PZ95-NR98
require File.dirname(__FILE__) + '/../../../test_helper'

module Graticule
  module Geocoder
    class PostcodeAnywhereTest < Test::Unit::TestCase

      def setup
        URI::HTTP.responses = []
        URI::HTTP.uris = []
        @geocoder = PostcodeAnywhere.new 'account_code', 'license_key'
      end

    def test_locate
      prepare_response(:success)
      location = Location.new(
        :street => "204 Campbell Ave",
        :locality => "Revelstoke",
        :region => "BC",
        :postal_code => "V0E",
        :country => "Canada",
        :longitude => -118.196970002204,
        :latitude => 50.9997350418267
      )
      assert_equal location, @geocoder.locate(:street => "204 Campbell Ave",
        :locality => "Revelstoke", :country => "Canada")
    end
    
    def test_locate_uk_address
      prepare_response(:uk)
      
      location = Location.new :latitude => 51.5728910186362, :longitude => -0.253788666693255
      assert_equal location, @geocoder.locate(:street => '80 Wood Lane', :locality => 'London', :country => 'UK')
    end
    
    def test_empty
      prepare_response(:empty)
      
      assert_raises(Graticule::AddressError) { @geocoder.locate :street => 'foobar'}
    end
  
    protected
      def prepare_response(id)
        URI::HTTP.responses << response('postcode_anywhere', id)
      end
  
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
GUI-graticule-0.2.7.2 test/unit/graticule/geocoder/postcode_anywhere_test.rb
GUI-graticule-0.2.7.3 test/unit/graticule/geocoder/postcode_anywhere_test.rb
GUI-graticule-0.2.7.4 test/unit/graticule/geocoder/postcode_anywhere_test.rb
GUI-graticule-0.2.7.5 test/unit/graticule/geocoder/postcode_anywhere_test.rb
GUI-graticule-0.2.7.6 test/unit/graticule/geocoder/postcode_anywhere_test.rb
norman-graticule-0.2.7 test/unit/graticule/geocoder/postcode_anywhere_test.rb
graticule-0.2.0 test/unit/graticule/geocoder/postcode_anywhere_test.rb
graticule-0.2.1 test/unit/graticule/geocoder/postcode_anywhere_test.rb
graticule-0.2.6 test/unit/graticule/geocoder/postcode_anywhere_test.rb
graticule-0.2.2 test/unit/graticule/geocoder/postcode_anywhere_test.rb
graticule-0.2.3 test/unit/graticule/geocoder/postcode_anywhere_test.rb
graticule-0.2.4 test/unit/graticule/geocoder/postcode_anywhere_test.rb
graticule-0.2.5 test/unit/graticule/geocoder/postcode_anywhere_test.rb