class RSpec::Sidekiq::NullBatch

Sidekiq::Batch is a Sidekiq::Pro feature. However the general consensus is that, by defeault, you can’t test without redis. RSpec::Sidekiq includes a “null object” pattern implementation to mock Batches. This will mock Sidekiq::Batch and prevent it from using Redis.

This is opt-in only feature.

RSpec.describe "Using mocked batches", stub_batches: true do
  it "uses mocked batches" do
    batch = Sidekiq::Batch.new
    batch.jobs do
      SomeJob.perform_async 123
    end

    expect(SomeJob).to have_enqueued_sidekiq_job
  end
end