sidekiq-testslisted
Install: claude install-skill testland/qa
# sidekiq-tests
## Overview
Sidekiq is the de facto Ruby background-job framework on Redis. The
testing model per [github.com/sidekiq/sidekiq/wiki/Testing][sk-test]:
[sk-test]: https://github.com/sidekiq/sidekiq/wiki/Testing
Three test modes:
| Mode | Behavior |
|---|---|
| `Sidekiq::Testing.fake!` | "pushes all jobs into a `jobs` array" (default in test env) |
| `Sidekiq::Testing.inline!` | "run jobs inline" (executes immediately, synchronously) |
| `Sidekiq::Testing.disable!` | "Enqueue jobs to Redis as normal" |
Choose **fake!** for unit tests (assert enqueueing without execution),
**inline!** for integration tests (test the worker itself end-to-end),
**disable!** for tests that need real Redis (e.g., scheduled-job
queries against the Sidekiq API).
## When to use
- The repo has `app/workers/*.rb` (or `app/jobs/*.rb`) with Sidekiq
classes.
- The user writes tests for job enqueueing logic (controllers /
services).
- Tests need to assert on job count, scheduled time, or arguments.
- A test verifies retry / dead-set / unique-job behavior.
## Step 1 - Configure test mode
In `spec_helper.rb` (RSpec) or `test_helper.rb` (Minitest):
```ruby
require 'sidekiq/testing'
Sidekiq::Testing.fake! # default for unit tests
```
Switch per-test when needed:
```ruby
it "actually runs the job" do
Sidekiq::Testing.inline! do
create(:order) # triggers OrderConfirmationWorker.perform_async
expect(...).to ...
end
end
```
## Step 2 - Clear jobs between tests