debian-mirror-gitlab/spec/support/helpers/idempotent_worker_helper.rb
2020-04-08 14:13:33 +05:30

16 lines
419 B
Ruby

# frozen_string_literal: true
module IdempotentWorkerHelper
WORKER_EXEC_TIMES = 2
def perform_multiple(args = [], worker: described_class.new, exec_times: WORKER_EXEC_TIMES)
Sidekiq::Testing.inline! do
job_args = args.nil? ? [nil] : Array.wrap(args)
expect(worker).to receive(:perform).exactly(exec_times).and_call_original
exec_times.times { worker.perform(*job_args) }
end
end
end