Sha256: bcd3fa9608bdc7a790806e9839f87dc5be6d2362fab84f0ab8bda5159a400a08
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
require 'spec_helper' require 'pathname' describe GeoNamesAPI::Entity do let(:filename) do (Pathname.new(__FILE__).parent + "place.ser").realdirpath end class TestPlace < GeoNamesAPI::ListEndpoint METHOD = "findNearbyJSON" FIND_PARAMS = %w(lat lng radius maxRows) end def ensure_place_exists unless filename.exist? puts "Sorry, #{filename} didn't exist yet. Run this test again." place = TestPlace.find(lat: 37.8018, lng: -122.3971, radius: 0.25) filename.open('wb') { |io| Marshal.dump(place, io) } end end # NOTE: if these fail, try deleting place.ser and re-running the spec. it 'round-trips when an Entity has not been loaded yet' do ensure_place_exists obj = Marshal.load(filename.open('rb')) expect(obj).to respond_to(:geoname_id) expect(obj).to respond_to(:country_code) expect(obj).to respond_to(:lat) expect(obj).to respond_to(:lng) expect(obj).to be_a(TestPlace) expect(obj.geoname_id).to eq(5382567) expect(obj.country_code).to eq('US') expect(obj.lat).to be_within(0.001).of(37.8018) expect(obj.lng).to be_within(0.001).of(-122.3971) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
geonames_api-0.1.6 | spec/geonames_api/marshalling_spec.rb |
geonames_api-0.1.5 | spec/geonames_api/marshalling_spec.rb |