Module: ResqueUnitWithoutMock::ResqueAssertions

Defined in:
lib/resque_unit_without_mock/resque_assertions.rb

Instance Method Summary collapse

Instance Method Details

#assert_not_queued(klass, args = nil, &block) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/resque_unit_without_mock/resque_assertions.rb', line 13

def assert_not_queued(klass, args = nil, &block)
  queue_name = Resque.queue_for(klass)
  queue = Resque.queued(queue_name).map{|x| JSON.parse(x) }
  assert(
    !in_queue?(queue, klass, args),
    "#{klass}#{args ? " with #{args.inspect}" : ""} should not have been queued in #{queue_name}.",
  )
end

#assert_queued(klass, args = nil, &block) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/resque_unit_without_mock/resque_assertions.rb', line 4

def assert_queued(klass, args = nil, &block)
  queue_name = Resque.queue_for(klass)
  queue = Resque.queued(queue_name).map{|x| JSON.parse(x) }
  assert(
    in_queue?(queue, klass, args),
    "#{klass}#{args ? " with #{args.inspect}" : ""} should have been queued in #{queue_name}: #{queue.inspect}.",
  )
end