From b76a009f43e7f49bcafd1c37f7252b736d062a26 Mon Sep 17 00:00:00 2001 From: Christian Schell Date: Thu, 13 Jul 2017 21:32:04 +0200 Subject: [PATCH] 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