2024-09-23 18:10:39 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
RSpec.describe Points::GpxSerializer do
|
|
|
|
|
describe '#call' do
|
2024-11-08 10:47:20 -05:00
|
|
|
subject(:serializer) { described_class.new(points, 'some_name').call }
|
2024-09-23 18:10:39 -04:00
|
|
|
|
|
|
|
|
let(:points) { create_list(:point, 3) }
|
|
|
|
|
|
|
|
|
|
it 'returns GPX file' do
|
|
|
|
|
expect(serializer).to be_a(GPX::GPXFile)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'includes waypoints' do
|
2024-11-08 10:47:20 -05:00
|
|
|
expect(serializer.tracks[0].points.size).to eq(3)
|
2024-09-23 18:10:39 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'includes waypoints with correct attributes' do
|
2024-11-08 10:47:20 -05:00
|
|
|
serializer.tracks[0].points.each_with_index do |track_point, index|
|
2024-09-23 18:10:39 -04:00
|
|
|
point = points[index]
|
2024-11-08 10:47:20 -05:00
|
|
|
|
|
|
|
|
expect(track_point.lat).to eq(point.latitude)
|
|
|
|
|
expect(track_point.lon).to eq(point.longitude)
|
|
|
|
|
expect(track_point.time).to eq(point.recorded_at)
|
2024-09-23 18:10:39 -04:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|