demarches-normaliennes/spec/services/geojson_service_spec.rb
2015-11-30 17:12:32 +01:00

34 lines
941 B
Ruby

require 'spec_helper'
describe GeojsonService do
describe '.toGeoJsonPolygon' do
subject { JSON.parse(described_class.to_json_polygon coordinates) }
describe 'coordinates are empty' do
let(:coordinates) { '' }
it { expect(subject['geo']['type']).to eq('Polygon') }
it { expect(subject['geo']['coordinates']).to eq([coordinates]) }
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['geo']['type']).to eq('Polygon') }
it { expect(subject['geo']['coordinates']).to eq([coordinates]) }
end
end
end