Sha256: fb4a43499df52179b484fa80d13f7cb025abfdd79573bd934216ef214aacef87

Contents?: true

Size: 912 Bytes

Versions: 5

Compression:

Stored size: 912 Bytes

Contents

require 'spec_helper'

describe GeoNamesAPI::Hierarchy do
  def should_be_sb(h)
    h.first.name.should == 'Earth'
    h.map { |ea| ea.name }.should ==
      ['Earth', 'North America', 'United States', 'California', 'Santa Barbara County', 'Santa Barbara']
  end

  def should_be_roma(h)
    h.map { |ea| ea.name }.should ==
      ['Terra', 'Europa', 'Italia', 'Lazio', 'Roma', 'Roma', 'Roma']
  end

  describe '::find' do
    it 'works for Santa Barbara' do
      h = GeoNamesAPI::Hierarchy.find(5392952)
      should_be_sb(h)
    end

    it 'works for Roma ' do
      begin
        GeoNamesAPI.lang = :it
        h = GeoNamesAPI::Hierarchy.find(3169070)
        should_be_roma(h)
      ensure
        GeoNamesAPI.lang = :en
      end
    end
  end

  describe '::where' do
    it 'works for Santa Barbara' do
      h = GeoNamesAPI::Hierarchy.where(geonameId: 5392952)
      should_be_sb(h)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
geonames_api-0.1.4 spec/geonames_api/hierarchy_spec.rb
geonames_api-0.1.3 spec/geonames_api/hierarchy_spec.rb
geonames_api-0.1.2 spec/geonames_api/hierarchy_spec.rb
geonames_api-0.1.1 spec/geonames_api/hierarchy_spec.rb
geonames_api-0.1.0 spec/geonames_api/hierarchy_spec.rb