Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
pkg/
.m/
.worktrees/
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
go_transit (1.2.0)
go_transit (1.3.0)
activesupport

GEM
Expand Down
3 changes: 2 additions & 1 deletion lib/go_transit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@

module GoTransit
@api_key = ""
@service_day_boundary_hour = 4

class << self
attr_accessor :api_key, :custom_base_url
attr_accessor :api_key, :custom_base_url, :service_day_boundary_hour

def configure
yield self
Expand Down
20 changes: 20 additions & 0 deletions lib/go_transit/api_resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,25 @@ def to_utc(date)
def to_local(date, timezone: "America/Toronto")
date.in_time_zone(timezone)
end

def to_utc_from_anchor(time, trip_date, timezone: "America/Toronto")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

to_local_from_anchor(time, trip_date, timezone: timezone)&.utc
end

def to_local_from_anchor(time, trip_date, timezone: "America/Toronto")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

raise MissingAnchorDateError if trip_date.nil?
return nil if time.blank?
hour = time.split(":").first.to_i

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

date = determine_date(trip_date, hour)
"#{date} #{time}".in_time_zone(timezone)
end

def determine_date(date, hour)
if hour < GoTransit.service_day_boundary_hour
date + 1.day
else
date
end
end
end
end
1 change: 1 addition & 0 deletions lib/go_transit/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ def initialize(metadata)
ForbiddenError = Class.new(ApiError)
NotFoundError = Class.new(ApiError)
TooManyRequestsError = Class.new(ApiError)
MissingAnchorDateError = Class.new(StandardError)
end
4 changes: 3 additions & 1 deletion lib/go_transit/resources/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def self.trip(date:, trip_number:)
formatted_date = date.strftime("%Y%m%d")
client = Client.new
response = client.get("Schedule/Trip/#{formatted_date}/#{trip_number}")
new(response.data).trips
trips = new(response.data).trips
trips.each { |trip| trip.anchor_date = date }
trips
end
end
end
16 changes: 16 additions & 0 deletions lib/go_transit/resources/schedule/journey/sch_journey.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
module GoTransit
class Schedule::Journey::SchJourney < ApiResource
attr_accessor :date, :time, :to, :from, :services

def initialize(params)
super
propagate_anchor_date
end

private

def propagate_anchor_date
parsed_date = Date.parse(date)
services.each do |service|
service.trips.each do |trip|
trip.stops.each { |stop| stop.anchor_date = parsed_date }
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
module GoTransit
class Schedule::Journey::SchJourney::Service::Trip::Stop < ApiResource
attr_accessor :code, :order, :time, :sorting_time, :is_major
attr_accessor :code, :order, :time, :sorting_time, :is_major, :anchor_date

def major?
is_major.to_i.positive?
end

def time_utc
to_utc_from_anchor(time, anchor_date)
end

def time_local
to_local_from_anchor(time, anchor_date)
end
end
end
4 changes: 4 additions & 0 deletions lib/go_transit/resources/schedule/trip.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ def time_stamp_utc
def time_stamp_local
to_local(time_stamp)
end

def anchor_date=(date)
stops.each { |stop| stop.anchor_date = date }
end
end
end
5 changes: 5 additions & 0 deletions lib/go_transit/resources/schedule/trip/stop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ module GoTransit
class Schedule::Trip::Stop < ApiResource
attr_accessor :arrival_time, :departure_time, :track, :code, :status,
:remark

def anchor_date=(date)
arrival_time.anchor_date = date
departure_time.anchor_date = date
end
end
end
18 changes: 17 additions & 1 deletion lib/go_transit/resources/schedule/trip/stop/arrival_time.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
module GoTransit
class Schedule::Trip::Stop::ArrivalTime < ApiResource
attr_accessor :scheduled, :computed, :status
attr_accessor :scheduled, :computed, :status, :anchor_date

def scheduled_utc
to_utc_from_anchor(scheduled, anchor_date)
end

def scheduled_local
to_local_from_anchor(scheduled, anchor_date)
end

def computed_utc
to_utc_from_anchor(computed, anchor_date)
end

def computed_local
to_local_from_anchor(computed, anchor_date)
end
end
end
18 changes: 17 additions & 1 deletion lib/go_transit/resources/schedule/trip/stop/departure_time.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
module GoTransit
class Schedule::Trip::Stop::DepartureTime < ApiResource
attr_accessor :scheduled, :computed, :status
attr_accessor :scheduled, :computed, :status, :anchor_date

def scheduled_utc
to_utc_from_anchor(scheduled, anchor_date)
end

def scheduled_local
to_local_from_anchor(scheduled, anchor_date)
end

def computed_utc
to_utc_from_anchor(computed, anchor_date)
end

def computed_local
to_local_from_anchor(computed, anchor_date)
end
end
end
4 changes: 0 additions & 4 deletions lib/go_transit/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ def payload_data(payload)
end

def throw_error
# A genuine transport-level 429 always wins, even if the JSON body
# (when there is one) claims success - GO Transit's own error
# convention embeds the real code in the body, but an upstream
# rate limiter returning 429 isn't guaranteed to follow that.
raise TooManyRequestsError.new(metadata) if http_status == 429
return if code == 200
raise NoContentError.new(metadata) if code == 204
Expand Down
2 changes: 1 addition & 1 deletion lib/go_transit/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module GoTransit
VERSION = "1.2.0".freeze
VERSION = "1.3.0".freeze

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end
39 changes: 39 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,45 @@ value itself. For example, `departure_time_utc` on a stop returns the
regular `departure_time` converted to UTC, and `departure_time_local`
returns the same time zoned to Toronto instead.

### Time-only fields (no date)

A few fields are returned as a bare time with no date at all (for
example `Schedule::Trip::Stop::ArrivalTime`/`DepartureTime#scheduled` and
`#computed`, and `Schedule::Journey::SchJourney::Service::Trip::Stop#time`).
Converting one of these to a real `Time` requires knowing which calendar
date it belongs to, and GO Transit's own "service date" doesn't line up
with calendar midnight: a service date that starts at 6am can run past
2am the next calendar day, and every stop in that overnight tail is still
part of the *original* service date, not the next one.

These fields still expose `_utc`/`_local`, resolved against a known
anchor date (the date you requested, for `Schedule.trip`, or the date
embedded in the response itself, for `Schedule::Journey.journey`, so you
never need to pass one in yourself). We use a boundry hours defined as
`GoTransit.service_day_boundary_hour` (default `4`). If the time is after
the boundry hour then it belongs to the day *after* the anchor date; otherwise
it's the anchor date itself. This correctly handles a trip whose very first stop
is already past midnight, with nothing else to compare it against. Optionally
you can change when this hour is. Local to Toronto time:

```ruby
GoTransit.configure do |config|
config.service_day_boundary_hour = 3
end
```

Calling `_utc`/`_local` on one of these fields without ever going through
`Schedule.trip`/`Schedule.journey` (e.g. constructing the resource class
directly) raises `GoTransit::MissingAnchorDateError` rather than silently
assuming "today".

One endpoint's time-only fields don't get this treatment yet:
`ServiceUpdate::Exceptions::Trip::Stop#sch_arrival`/`#sch_departure`/
`#actual_time` are always `null` in every real response we've captured, so
their actual non-null format is unconfirmed, and the endpoint gives no
date to anchor them to either way. If you can confirm a real non-null
value for these fields, a PR is welcome.

## Missing Test Data
At the time of development I was unable to get test data for the following
endpoints. Some of these seem like they are restricted access endpoints and my
Expand Down
15 changes: 15 additions & 0 deletions spec/go_transit_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RSpec.describe GoTransit do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

describe ".service_day_boundary_hour" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

it "defaults to 4" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

expect(GoTransit.service_day_boundary_hour).to eq(4)
end

it "can be overridden via configure" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

GoTransit.configure { |config| config.service_day_boundary_hour = 3 }

expect(GoTransit.service_day_boundary_hour).to eq(3)

GoTransit.configure { |config| config.service_day_boundary_hour = 4 }
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,27 @@
end
end
end

describe "#time_local and #time_utc" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

it "resolve using the assigned anchor_date" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

stop = GoTransit::Schedule::Journey::SchJourney::Service::Trip::Stop.new(time: "07:00")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [93/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

stop.anchor_date = Date.new(2026, 1, 1)

expect(stop.time_local.to_date).to eq(Date.new(2026, 1, 1))
expect(stop.time_utc).to eq(stop.time_local.utc)
end

it "rolls forward past the boundary hour, same rule as Schedule::Trip's stops" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [85/80]

stop = GoTransit::Schedule::Journey::SchJourney::Service::Trip::Stop.new(time: "00:15")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [93/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

stop.anchor_date = Date.new(2026, 1, 1)

expect(stop.time_local.to_date).to eq(Date.new(2026, 1, 2))
end

it "raises MissingAnchorDateError when anchor_date was never assigned" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

stop = GoTransit::Schedule::Journey::SchJourney::Service::Trip::Stop.new(time: "07:00")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [93/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


expect { stop.time_local }.to raise_error(GoTransit::MissingAnchorDateError)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [82/80]

end
end
end
82 changes: 82 additions & 0 deletions spec/resources/schedule/trip/stop/arrival_time_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
RSpec.describe GoTransit::Schedule::Trip::Stop::ArrivalTime do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [56/25]
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

describe "#scheduled_local" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/BlockLength: Block has too many lines. [38/25]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

it "stays on the anchor date when the hour is at or after the boundary" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "23:58")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [89/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time.anchor_date = Date.new(2026, 1, 1)

result = arrival_time.scheduled_local

expect(result).to eq(Date.new(2026, 1, 1).in_time_zone("America/Toronto") + 23.hours + 58.minutes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [104/80]

end

it "rolls forward to the next day when the hour is before the boundary" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "00:04")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [89/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time.anchor_date = Date.new(2026, 1, 1)

result = arrival_time.scheduled_local

expect(result).to eq(Date.new(2026, 1, 2).in_time_zone("America/Toronto") + 4.minutes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [92/80]

end

it "rolls forward even when it is the trip's very first stop, with no prior stop to compare against" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [107/80]

# This is the whole point of a fixed boundary hour rather than
# sequence-based rollover detection: a trip whose first stop is
# already in the "overnight tail" of the previous service date
# rolls forward correctly with no other stop involved at all.
arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "01:00")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [89/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time.anchor_date = Date.new(2026, 1, 1)

result = arrival_time.scheduled_local

expect(result.to_date).to eq(Date.new(2026, 1, 2))
end

it "honors a custom service_day_boundary_hour" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

original_boundary_hour = GoTransit.service_day_boundary_hour
GoTransit.service_day_boundary_hour = 3
arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "03:30")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [89/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time.anchor_date = Date.new(2026, 1, 1)

result = arrival_time.scheduled_local

expect(result.to_date).to eq(Date.new(2026, 1, 1))
ensure
GoTransit.service_day_boundary_hour = original_boundary_hour
end

it "returns nil when the underlying field is blank" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [84/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time.anchor_date = Date.new(2026, 1, 1)

expect(arrival_time.scheduled_local).to be_nil
end

it "raises MissingAnchorDateError when anchor_date was never assigned" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "14:54")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [89/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.


expect { arrival_time.scheduled_local }.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the next line, together with the method name.

to raise_error(GoTransit::MissingAnchorDateError)
end
end

describe "#scheduled_utc" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

it "converts the resolved local time to UTC" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "14:54")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [89/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time.anchor_date = Date.new(2026, 1, 1)

result = arrival_time.scheduled_utc

expect(result).to eq(Date.new(2026, 1, 1).in_time_zone("America/Toronto").utc + 14.hours + 54.minutes)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Metrics/LineLength: Line is too long. [108/80]

end
end

describe "#computed_local and #computed_utc" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

it "resolve the same way as scheduled, independently" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time = GoTransit::Schedule::Trip::Stop::ArrivalTime.new(scheduled: "14:54", computed: "15:01")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [108/80]
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

arrival_time.anchor_date = Date.new(2026, 1, 1)

expect(arrival_time.computed_local.strftime("%H:%M")).to eq("15:01")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

expect(arrival_time.computed_utc).to eq(arrival_time.computed_local.utc)
end
end
end
29 changes: 29 additions & 0 deletions spec/resources/schedule/trip/stop/departure_time_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
RSpec.describe GoTransit::Schedule::Trip::Stop::DepartureTime do
describe "#scheduled_local and #scheduled_utc" do
it "resolve using the assigned anchor_date, same as ArrivalTime" do
departure_time = GoTransit::Schedule::Trip::Stop::DepartureTime.new(scheduled: "00:04")
departure_time.anchor_date = Date.new(2026, 1, 1)

expect(departure_time.scheduled_local.to_date).to eq(Date.new(2026, 1, 2))
expect(departure_time.scheduled_utc).to eq(departure_time.scheduled_local.utc)
end
end

describe "#computed_local and #computed_utc" do
it "resolve independently of scheduled" do
departure_time = GoTransit::Schedule::Trip::Stop::DepartureTime.new(computed: "14:54")
departure_time.anchor_date = Date.new(2026, 1, 1)

expect(departure_time.computed_local.strftime("%H:%M")).to eq("14:54")
end
end

describe "without an anchor_date" do
it "raises MissingAnchorDateError" do
departure_time = GoTransit::Schedule::Trip::Stop::DepartureTime.new(scheduled: "14:54")

expect { departure_time.scheduled_local }.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/DotPosition: Place the . on the next line, together with the method name.

to raise_error(GoTransit::MissingAnchorDateError)
end
end
end
Loading
Loading