File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
spec/rspec/rails/matchers Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,8 @@ def self.find(_id)
33
33
end
34
34
35
35
RSpec . describe "ActiveJob matchers" , skip : !RSpec ::Rails ::FeatureCheck . has_active_job? do
36
+ include ActiveSupport ::Testing ::TimeHelpers if defined? ( ActiveSupport ::Testing ::TimeHelpers )
37
+
36
38
around do |example |
37
39
original_logger = ActiveJob ::Base . logger
38
40
ActiveJob ::Base . logger = Logger . new ( nil ) # Silence messages "[ActiveJob] Enqueued ...".
@@ -223,6 +225,14 @@ def self.name; "LoggingJob"; end
223
225
} . to have_enqueued_job . at ( time )
224
226
end
225
227
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
232
+ expect { hello_job . set ( wait : 5 ) . perform_later } . to have_enqueued_job . at ( time + 5 )
233
+ end
234
+ end
235
+
226
236
it "accepts composable matchers as an at date" do
227
237
future = 1 . minute . from_now
228
238
slightly_earlier = 58 . seconds . from_now
You can’t perform that action at this time.
0 commit comments