mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Add a very lousy spec for GPX serializer
This commit is contained in:
parent
24726aa4d1
commit
3238fb64e6
2 changed files with 47 additions and 0 deletions
30
spec/serializers/points/geojson_serializer_spec.rb
Normal file
30
spec/serializers/points/geojson_serializer_spec.rb
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Points::GeojsonSerializer do
|
||||||
|
describe '#call' do
|
||||||
|
subject(:serializer) { described_class.new(points).call }
|
||||||
|
|
||||||
|
let(:points) { create_list(:point, 3) }
|
||||||
|
let(:expected_json) do
|
||||||
|
{
|
||||||
|
type: 'FeatureCollection',
|
||||||
|
features: points.map do |point|
|
||||||
|
{
|
||||||
|
type: 'Feature',
|
||||||
|
geometry: {
|
||||||
|
type: 'Point',
|
||||||
|
coordinates: [point.longitude, point.latitude]
|
||||||
|
},
|
||||||
|
properties: PointSerializer.new(point).call
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns JSON' do
|
||||||
|
expect(serializer).to eq(expected_json.to_json)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
17
spec/serializers/points/gpx_serializer.rb
Normal file
17
spec/serializers/points/gpx_serializer.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe Points::GpxSerializer do
|
||||||
|
describe '#call' do
|
||||||
|
subject(:serializer) { described_class.new(points).call }
|
||||||
|
|
||||||
|
let(:points) { create_list(:point, 3) }
|
||||||
|
let(:geojson_data) { Points::GeojsonSerializer.new(points).call }
|
||||||
|
let(:gpx) { GPX::GeoJSON.convert_to_gpx(geojson_data:) }
|
||||||
|
|
||||||
|
it 'returns JSON' do
|
||||||
|
expect(serializer).to be_a(GPX::GPXFile)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in a new issue