Sha256: fe1dfaaa365f79fc2a3de17218040a0c94fc18efe26ca88672454ec30e298040

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require File.join(File.dirname(__FILE__), "helper")

Geokit::Geocoders::MapboxGeocoder.key = ""

class MapboxGeocoderTest < BaseGeocoderTest #:nodoc: all
  def setup
    super
    @address = "1714 14th Street NW, Washington, DC"
    @latlng = Geokit::LatLng.new(38.913175, -77.032458)
    @city = "Washington, DC"
  end

  def test_forward_geocode
    VCR.use_cassette("mapbox_forward_geocode") do
      res = Geokit::Geocoders::MapboxGeocoder.geocode(@address)
      assert_equal 38.913184, res.lat
      assert_equal(-77.031952, res.lng)
      assert_equal "United States", res.country
      assert_equal "District of Columbia", res.state
      assert_equal "20009", res.zip
    end
  end

  def test_reverse_geocode
    VCR.use_cassette("mapbox_reverse_geocode") do
      res = Geokit::Geocoders::MapboxGeocoder.reverse_geocode(@latlng)
      assert_equal "United States", res.country
      assert_equal "District of Columbia", res.state
      assert_equal "20009", res.zip
    end
  end

  def test_city_only
    VCR.use_cassette("mapbox_forward_geocode_city_only") do
      res = Geokit::Geocoders::MapboxGeocoder.geocode(@city)
      assert_equal 38.8951, res.lat
      assert_equal(-77.0364, res.lng)
      assert_equal "United States", res.country
      assert_equal "District of Columbia", res.state
      assert_equal "Washington", res.city
      assert_equal "20004", res.zip
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geokit-1.10.0 test/test_mapbox_geocoder.rb