Module: ResqueUnit::SchedulerAssertions
- Defined in:
- lib/resque_unit/scheduler_assertions.rb
Instance Method Summary collapse
-
#assert_not_queued_at(expected_timestamp, klass, args = nil, message = nil) ⇒ Object
opposite of
assert_queued_at
. -
#assert_not_queued_in(expected_time_difference, klass, args = nil, message = nil) ⇒ Object
opposite of
assert_queued_in
. -
#assert_queued_at(expected_timestamp, klass, args = nil, message = nil) ⇒ Object
Asserts that
klass
has been queued into its appropriate queue at least once, with atimestamp
less than or equal toexpected_timestamp
. -
#assert_queued_in(expected_time_difference, klass, args = nil, message = nil) ⇒ Object
Similar to
assert_queued_at
, except it takes an expected time difference (in seconds) instead of a timestamp.
Instance Method Details
#assert_not_queued_at(expected_timestamp, klass, args = nil, message = nil) ⇒ Object
opposite of assert_queued_at
29 30 31 32 33 34 |
# File 'lib/resque_unit/scheduler_assertions.rb', line 29 def assert_not_queued_at(, klass, args = nil, = nil) queue = Resque.queue_for(klass) assert_block ( || "#{klass} should not have been queued in #{queue} before #{}.") do !(queue, , klass, args) end end |
#assert_not_queued_in(expected_time_difference, klass, args = nil, message = nil) ⇒ Object
opposite of assert_queued_in
37 38 39 |
# File 'lib/resque_unit/scheduler_assertions.rb', line 37 def assert_not_queued_in(expected_time_difference, klass, args = nil, = nil) assert_not_queued_at(Time.now + expected_time_difference, klass, args, ) end |
#assert_queued_at(expected_timestamp, klass, args = nil, message = nil) ⇒ Object
Asserts that klass
has been queued into its appropriate queue at least once, with a timestamp
less than or equal to expected_timestamp
. If the job wasn’t queued with a timestamp, the assertion fails.. If args
is nil, it only asserts that the klass has been queued. Otherwise, it asserts that the klass has been queued with the correct arguments. Pass an empty array for args
if you want to assert that klass has been queued without arguments.
15 16 17 18 19 20 |
# File 'lib/resque_unit/scheduler_assertions.rb', line 15 def assert_queued_at(, klass, args = nil, = nil) queue = Resque.queue_for(klass) assert_block ( || "#{klass} should have been queued in #{queue} before #{}: #{Resque.queue(queue).inspect}.") do (queue, , klass, args) end end |
#assert_queued_in(expected_time_difference, klass, args = nil, message = nil) ⇒ Object
Similar to assert_queued_at
, except it takes an expected time difference (in seconds) instead of a timestamp.
24 25 26 |
# File 'lib/resque_unit/scheduler_assertions.rb', line 24 def assert_queued_in(expected_time_difference, klass, args = nil, = nil) assert_queued_at(Time.now + expected_time_difference, klass, args, ) end |