wspurgin / rspec-sidekiq

RSpec for Sidekiq
https://github.com/wspurgin/rspec-sidekiq
Other
663 stars 132 forks source link

Testing the sidekiq_retry_in for workers #159

Closed maxrosecollins closed 1 year ago

maxrosecollins commented 5 years ago

I checked the docs but couldn't see it. How am I able to test the sidekiq_retry_in with rspec?

Thanks!

eduardoprentcomau commented 4 years ago

I managed to test this way (running sidekiq 5.2.7):

class WorkerEvent
  include Sidekiq::Worker

  sidekiq_options retry: 5

  sidekiq_retry_in { 600 }
end

RSpec.describe WorkerEvent do
  describe 'retry' do
    subject(:config) { described_class }

    it { is_expected.to be_retryable 5 }

    it 'delays the retries in 10 minutes' do
      expect(config.sidekiq_retry_in_block.call).to eq 600
    end
  end
end