File tree 2 files changed +27
-1
lines changed
spec/rspec/rails/matchers
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -140,8 +140,9 @@ def job_match?(job)
140
140
141
141
def arguments_match? ( job )
142
142
if @args . any?
143
+ args = serialize_and_deserialize_arguments ( @args )
143
144
deserialized_args = deserialize_arguments ( job )
144
- RSpec ::Mocks ::ArgumentListMatcher . new ( *@ args) . args_match? ( *deserialized_args )
145
+ RSpec ::Mocks ::ArgumentListMatcher . new ( *args ) . args_match? ( *deserialized_args )
145
146
else
146
147
true
147
148
end
@@ -172,6 +173,13 @@ def set_expected_number(relativity, count)
172
173
end
173
174
end
174
175
176
+ def serialize_and_deserialize_arguments ( args )
177
+ serialized = ::ActiveJob ::Arguments . serialize ( args )
178
+ ::ActiveJob ::Arguments . deserialize ( serialized )
179
+ rescue ::ActiveJob ::SerializationError
180
+ args
181
+ end
182
+
175
183
def deserialize_arguments ( job )
176
184
::ActiveJob ::Arguments . deserialize ( job [ :args ] )
177
185
rescue ::ActiveJob ::DeserializationError
Original file line number Diff line number Diff line change @@ -328,6 +328,24 @@ def self.name; "LoggingJob"; end
328
328
expect ( arg ) . to eq ( "asdf" )
329
329
}
330
330
end
331
+
332
+ if Rails . version . to_f >= 6.0
333
+ it "passes with Time" do
334
+ usec_time = Time . iso8601 ( '2016-07-01T00:00:00.000001Z' )
335
+
336
+ expect {
337
+ hello_job . perform_later ( usec_time )
338
+ } . to have_enqueued_job ( hello_job ) . with ( usec_time )
339
+ end
340
+
341
+ it "passes with ActiveSupport::TimeWithZone" do
342
+ usec_time = Time . iso8601 ( '2016-07-01T00:00:00.000001Z' ) . in_time_zone
343
+
344
+ expect {
345
+ hello_job . perform_later ( usec_time )
346
+ } . to have_enqueued_job ( hello_job ) . with ( usec_time )
347
+ end
348
+ end
331
349
end
332
350
333
351
describe "have_been_enqueued" do
You can’t perform that action at this time.
0 commit comments