Sha256: 0300955f564a3e6ce046e5660acd69ce8031374eaec00aeeb9f79b333ee7e1e2

Contents?: true

Size: 1.14 KB

Versions: 6

Compression:

Stored size: 1.14 KB

Contents

# encoding: UTF-8
require 'test_helper'

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

      def setup
        URI::HTTP.responses = []
        URI::HTTP.uris = []
        @geocoder = SimpleGeo.new('TOKEN')
      end

      def test_success
        return unless prepare_response(:success)

        location = Location.new(
          :longitude => -117.373982,
          :latitude => 34.482358,
          :precision => :unknown
        )
        assert_equal location, @geocoder.locate('1600 Amphitheatre Parkway, Mountain View, CA')
      end

      def test_error
        prepare_response :error
        assert_raises(Error) { @geocoder.locate('') }
      end

      def test_time_zone
        URI::HTTP.uris = []
        URI::HTTP.responses = []
        URI::HTTP.responses << response('simple_geo', :success, 'json')
        los_angeles = Location.new(:latitude => 34.48, :longitude => -117.37)
        assert_equal 'America/Los_Angeles', @geocoder.time_zone(los_angeles)
      end

    private

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

Version data entries

6 entries across 6 versions & 1 rubygems

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