2016-12-16 10:42:34 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-10-15 21:01:37 +02:00
|
|
|
describe ApiGeo::API do
|
2018-10-15 16:30:27 +02:00
|
|
|
describe '.regions', vcr: { cassette_name: 'api_geo_regions' } do
|
2016-12-16 10:42:34 +01:00
|
|
|
subject { described_class.regions }
|
|
|
|
|
2018-10-23 15:35:03 +02:00
|
|
|
it { expect(subject.size).to eq 18 }
|
2016-12-16 10:42:34 +01:00
|
|
|
end
|
|
|
|
|
2018-10-15 16:30:27 +02:00
|
|
|
describe '.departements', vcr: { cassette_name: 'api_geo_departements' } do
|
2016-12-16 10:42:34 +01:00
|
|
|
subject { described_class.departements }
|
|
|
|
|
2018-10-23 15:35:03 +02:00
|
|
|
it { expect(subject.size).to eq 101 }
|
2016-12-16 10:42:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
describe '.pays' do
|
|
|
|
subject { described_class.pays }
|
2018-10-23 15:35:03 +02:00
|
|
|
let(:pays) {
|
|
|
|
JSON.parse(File.open('app/lib/api_geo/pays.json').read, symbolize_names: true)
|
|
|
|
}
|
2016-12-16 10:42:34 +01:00
|
|
|
|
2018-10-23 15:35:03 +02:00
|
|
|
it { is_expected.to eq pays }
|
2016-12-16 10:42:34 +01:00
|
|
|
end
|
2018-10-23 17:01:15 +02:00
|
|
|
|
|
|
|
describe '.search_rpg', vcr: { cassette_name: 'api_geo_search_rpg' } do
|
|
|
|
let(:coordinates) do
|
|
|
|
[
|
|
|
|
[
|
|
|
|
2.3945903778076176,
|
|
|
|
46.53312237252731
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.394933700561524,
|
|
|
|
46.532590956418076
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.3948478698730473,
|
|
|
|
46.53170525134736
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.393732070922852,
|
|
|
|
46.530760483351195
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.3909854888916016,
|
|
|
|
46.5309376286023
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.391414642333985,
|
|
|
|
46.531232869403546
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.3913288116455083,
|
|
|
|
46.53253190986272
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.39278793334961,
|
|
|
|
46.53329951007484
|
|
|
|
],
|
|
|
|
[
|
|
|
|
2.3945903778076176,
|
|
|
|
46.53312237252731
|
|
|
|
]
|
|
|
|
]
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:geo_json) {
|
|
|
|
GeojsonService.to_json_polygon_for_rpg(coordinates)
|
|
|
|
}
|
|
|
|
|
|
|
|
subject { described_class.search_rpg(geo_json) }
|
|
|
|
|
|
|
|
it { expect(subject[:features].size).to eq 3 }
|
|
|
|
end
|
2017-04-04 15:27:04 +02:00
|
|
|
end
|