Sha256: c9f50fd0761ae3803af757d3f42a45b65452723560af3ec9bd31221bd1e8e267
Contents?: true
Size: 985 Bytes
Versions: 4
Compression:
Stored size: 985 Bytes
Contents
require File.join File.dirname(__FILE__), 'env.rb' include CartoJson describe CartoJson::Polygon do before do @args = {:points => [ {LAT => 45.52, LNG => -122.681944}, {LAT => 45.53, LNG => -122.681945}, {LAT => 45.54, LNG => -122.681946}]} end it 'should create a polygon with valid data' do p = Polygon.new @args p.type.must_equal :polygon p.class.type.must_equal :polygon p.points.first.class.must_equal Point hash = MultiJson.decode(p.to_json, :symbolize_keys => true) hash[:points].length.must_equal 3 hash[:points].first[LAT].must_equal @args[:points].first[LAT] hash[:points].first[LNG].must_equal @args[:points].first[LNG] p.to_wkt.must_equal "POLYGON ((#{p.points.dup.push(p.points.first).collect {|p| "#{p.send(LNG)} #{p.send(LAT)}"}.join(', ')}))" end it 'should fail if less than three points' do @args[:points].pop lambda { Polygon.new @args }.must_raise InsufficientPointsError end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
carto_json-0.0.9 | spec/polygon_spec.rb |
carto_json-0.0.8 | spec/polygon_spec.rb |
carto_json-0.0.7 | spec/polygon_spec.rb |
carto_json-0.0.6 | spec/polygon_spec.rb |