Skip to content

Commit 5dacbc0

Browse files
JonRowepirj
authored andcommitted
Improve spec for offset times to not need freeze_time
1 parent ef3a5e6 commit 5dacbc0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

spec/rspec/rails/matchers/active_job_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ def self.name; "LoggingJob"; end
225225
}.to have_enqueued_job.at(time)
226226
end
227227

228-
skip_freeze_time = method_defined?(:freeze_time) ? false : "#freeze_time is undefined"
229-
it "works with time offsets", skip: skip_freeze_time do
230-
freeze_time do
231-
time = Time.current
228+
it "works with time offsets" do
229+
# note that Time.current does not replicate Rails behavior for 5 seconds from now.
230+
time = Time.current.change(usec: 0)
231+
travel_to time do
232232
expect { hello_job.set(wait: 5).perform_later }.to have_enqueued_job.at(time + 5)
233233
end
234234
end

0 commit comments

Comments
 (0)