From b76a009f43e7f49bcafd1c37f7252b736d062a26 Mon Sep 17 00:00:00 2001 From: Christian Schell Date: Thu, 13 Jul 2017 21:32:04 +0200 Subject: [PATCH 1/2] Add spec to demonstrate #46 This spec shows the reasons why the reported exception in #46 gets thrown. --- spec/mongoid/geospatial/fields/polygon_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/mongoid/geospatial/fields/polygon_spec.rb b/spec/mongoid/geospatial/fields/polygon_spec.rb index b524877..14e3de0 100644 --- a/spec/mongoid/geospatial/fields/polygon_spec.rb +++ b/spec/mongoid/geospatial/fields/polygon_spec.rb @@ -38,6 +38,16 @@ expect(geom.radius_sphere(10)[1]).to be_within(0.001).of(0.001569) end + it 'should handle BSON::Documents containing GeoJSON data' do + coordinates = [[[1, 1], [1, 2], [1, 1]]] + + document = BSON::Document.new(type: 'Polygon', coordinates: coordinates) + + geom = Mongoid::Geospatial::Polygon.new(document) + + expect([*geom]).to eq(corrdinates) + end + describe 'with rgeo' do # farm.area.should be_a RGeo::Geographic::SphericalPolygonImpl end From c8cdd7a003fc11e9eaf2f99a86f63cea9348862a Mon Sep 17 00:00:00 2001 From: Christian Schell Date: Thu, 13 Jul 2017 22:54:06 +0200 Subject: [PATCH 2/2] Fix typo --- spec/mongoid/geospatial/fields/polygon_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mongoid/geospatial/fields/polygon_spec.rb b/spec/mongoid/geospatial/fields/polygon_spec.rb index 14e3de0..c71ba54 100644 --- a/spec/mongoid/geospatial/fields/polygon_spec.rb +++ b/spec/mongoid/geospatial/fields/polygon_spec.rb @@ -45,7 +45,7 @@ geom = Mongoid::Geospatial::Polygon.new(document) - expect([*geom]).to eq(corrdinates) + expect([*geom]).to eq(coordinates) end describe 'with rgeo' do