dawarich/spec/support/point_helpers.rb
2025-07-16 22:22:33 +02:00

20 lines
573 B
Ruby

# frozen_string_literal: true
module PointHelpers
# Creates a list of points spaced ~100m apart northwards
def create_points_around(user:, count:, base_lat: 20.0, base_lon: 10.0, timestamp: nil, **attrs)
Array.new(count) do |i|
create(
:point,
user: user,
timestamp: (timestamp.respond_to?(:call) ? timestamp.call(i) : timestamp) || (Time.current - i.minutes).to_i,
lonlat: "POINT(#{base_lon} #{base_lat + i * 0.0009})",
**attrs
)
end
end
end
RSpec.configure do |config|
config.include PointHelpers
end