Sha256: c7efc52f42eda4468868e788fd7d81f99a1525cbba689317e7651c3a358c70b1

Contents?: true

Size: 1.49 KB

Versions: 6

Compression:

Stored size: 1.49 KB

Contents

# encoding: UTF-8
require 'test_helper'

module Graticule

  # Generic tests for all geocoders (theoretically)
  module GeocodersTestCase

    def test_success
      return unless prepare_response(:success)

      location = Location.new(
        :street => "1600 Amphitheatre Pkwy",
        :city => "Mountain View",
        :state => "CA",
        :zip => "94043",
        :country => "US",
        :longitude => -122.083739,
        :latitude => 37.423021,
        :precision => :address
      )
      assert_equal location, @geocoder.locate('1600 Amphitheatre Parkway, Mountain View, CA')
    end

    def test_bad_key
      return unless prepare_response(:badkey)
      assert_raises(CredentialsError) { @geocoder.locate('x') }
    end

    def test_locate_missing_address
      return unless prepare_response(:missing_address)
      assert_raises(AddressError) { @geocoder.locate 'x' }
    end

    def test_locate_server_error
      return unless prepare_response(:server_error)
      assert_raises(Error) { @geocoder.locate 'x' }
    end

    def test_locate_too_many_queries
      return unless prepare_response(:limit)
      assert_raises(CredentialsError) { @geocoder.locate 'x' }
    end

    def test_locate_unavailable_address
      return unless prepare_response(:unavailable)
      assert_raises(AddressError) { @geocoder.locate 'x' }
    end

    def test_locate_unknown_address
      return unless prepare_response(:unknown_address)
      assert_raises(AddressError) { @geocoder.locate 'x' }
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graticule-2.7.2 test/graticule/geocoder/geocoders.rb
graticule-2.7.1 test/graticule/geocoder/geocoders.rb
graticule-2.7.0 test/graticule/geocoder/geocoders.rb
graticule-2.6.0 test/graticule/geocoder/geocoders.rb
graticule-2.5.0 test/graticule/geocoder/geocoders.rb
graticule-2.4.0 test/graticule/geocoder/geocoders.rb