Sha256: cced7ad538a9c032886253362aea5d139d81f82058adf9fa809a0b87e47f5563

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

# encoding: UTF-8
require 'test_helper'

module Graticule
  module Geocoder
    class GeonamesTest < Test::Unit::TestCase
      def setup
        URI::HTTP.responses = []
        URI::HTTP.uris = []
        @geocoder = Geonames.new("demo")
      end

      def test_time_zone
        URI::HTTP.uris = []
        URI::HTTP.responses = []
        URI::HTTP.responses << response('geonames', :success)
        chicago = Location.new(:latitude => 41.85, :longitude => -87.65)
        assert_equal 'America/Chicago', @geocoder.time_zone(chicago)
      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

    protected

      def prepare_response(id = :success)
        URI::HTTP.responses << response('geonames', id)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
graticule-2.7.2 test/graticule/geocoder/geonames_test.rb
graticule-2.7.1 test/graticule/geocoder/geonames_test.rb
graticule-2.7.0 test/graticule/geocoder/geonames_test.rb
graticule-2.6.0 test/graticule/geocoder/geonames_test.rb