Add a very lousy spec for GPX serializer

This commit is contained in:
Eugene Burmakin 2024-09-02 22:01:51 +02:00
parent 24726aa4d1
commit 3238fb64e6
2 changed files with 47 additions and 0 deletions

View 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

View 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