lib/sidekiq/testing.rb in sidekiq-2.12.0 vs lib/sidekiq/testing.rb in sidekiq-2.12.1
- old
+ new
@@ -1,7 +1,9 @@
module Sidekiq
+ class EmptyQueueError < RuntimeError; end
+
class Client
class << self
alias_method :raw_push_old, :raw_push
def raw_push(payloads)
@@ -84,9 +86,16 @@
# Drain and run all jobs for this worker
def drain
while job = jobs.shift do
new.perform(*job['args'])
end
+ end
+
+ # Pop out a single job and perform it
+ def perform_one
+ raise(EmptyQueueError, "perform_one called with empty job queue") if jobs.empty?
+ job = jobs.shift
+ new.perform(*job['args'])
end
end
class << self
def jobs # :nodoc: