Skip to content

Commit

Permalink
Improve spec for offset times to not need freeze_time
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed May 28, 2020
1 parent aa0cd35 commit 6ca741f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spec/rspec/rails/matchers/active_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ def self.name; "LoggingJob"; end
}.to have_enqueued_job.at(time)
end

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

0 comments on commit 6ca741f

Please sign in to comment.