Module: ResqueUnitWithoutMock::SchedulerAssertions

Defined in:
lib/resque_unit_without_mock/scheduler_assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_not_queued_at(expected_timestamp, klass) ⇒ Object



6
7
8
# File 'lib/resque_unit_without_mock/scheduler_assertions.rb', line 6

def assert_not_queued_at(expected_timestamp, klass)
  assert_not_queued_at_with_queue(Resque.queue_for(klass), expected_timestamp, klass)
end

#assert_not_queued_at_with_queue(queue, expected_timestamp, klass) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/resque_unit_without_mock/scheduler_assertions.rb', line 18

def assert_not_queued_at_with_queue(queue, expected_timestamp, klass)
  result = Resque.enqueue_ats(queue).detect { |hash| hash[:timestamp] <= expected_timestamp && hash[:klass] == klass }
  assert(
    !result,
    "#{klass} should not have been queued in #{Resque.enqueue_ats(queue)} before #{expected_timestamp}"
  )
end

#assert_queued_at(expected_timestamp, klass) ⇒ Object



2
3
4
# File 'lib/resque_unit_without_mock/scheduler_assertions.rb', line 2

def assert_queued_at(expected_timestamp, klass)
  assert_queued_at_with_queue(Resque.queue_for(klass), expected_timestamp, klass)
end

#assert_queued_at_with_queue(queue, expected_timestamp, klass) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/resque_unit_without_mock/scheduler_assertions.rb', line 10

def assert_queued_at_with_queue(queue, expected_timestamp, klass)
  result = Resque.enqueue_ats(queue).detect { |hash| hash[:timestamp] <= expected_timestamp && hash[:klass] == klass }
  assert(
    result,
    "#{klass} should have been queued in #{Resque.enqueue_ats(queue)} before #{expected_timestamp}"
  )
end