2015-11-23 18:41:48 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GeojsonService do
|
|
|
|
describe '.toGeoJsonPolygon' do
|
|
|
|
|
|
|
|
let(:to_polygon_return) {
|
|
|
|
{
|
|
|
|
geo: {
|
|
|
|
type: "Polygon",
|
|
|
|
coordinates: [coordinates]
|
|
|
|
}
|
2015-11-25 10:26:55 +01:00
|
|
|
}.to_json
|
2015-11-23 18:41:48 +01:00
|
|
|
}
|
|
|
|
|
2015-11-25 10:26:55 +01:00
|
|
|
subject { described_class.to_json_polygon coordinates }
|
2015-11-23 18:41:48 +01:00
|
|
|
|
|
|
|
describe 'coordinates are empty' do
|
|
|
|
let(:coordinates) { '' }
|
|
|
|
|
|
|
|
it { expect(subject).to eq(to_polygon_return) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'coordinates are informed' do
|
|
|
|
let(:coordinates) {
|
|
|
|
[
|
|
|
|
[5.93536376953125,
|
|
|
|
48.91888968903368],
|
|
|
|
[5.93536376953125,
|
|
|
|
49.26780455063753],
|
|
|
|
[7.094421386718749,
|
|
|
|
49.26780455063753],
|
|
|
|
[7.094421386718749,
|
|
|
|
48.91888968903368],
|
|
|
|
[5.93536376953125,
|
|
|
|
48.91888968903368]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
it { expect(subject).to eq(to_polygon_return) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|