Skip to content

Releases: wspurgin/rspec-sidekiq

v5.3.0

23 Feb 00:49
e6f9344

Choose a tag to compare

Features

🆕 have_job matcher

New matcher for asserting jobs in Sidekiq named queues (ScheduledSet, RetrySet, DeadSet), with support for argument, count, and set-specific filters. Also introduces opt-in
in-memory named queue stubs via stub_named_queues: true for testing without Redis.

expect(Sidekiq::ScheduledSet).to have_job(AwesomeJob).with("arg")
expect(Sidekiq::RetrySet).to have_job(AwesomeJob).with_error("boom").with_retry_count(2)
expect(Sidekiq::DeadSet).to have_job(AwesomeJob).died_within(60)

# any job
expect(Sidekiq::ScheduledSet).to have_job

# stub named queues in tests (no Redis required)
RSpec.describe "test", stub_named_queues: true do
  it "works without Redis" do
    AwesomeJob.perform_at(1.hour.from_now, "arg")
    expect(Sidekiq::ScheduledSet).to have_job(AwesomeJob).with("arg")
  end
end

🆕 have_job_option / have_job_options matchers

New matchers for asserting job options (e.g. retry, queue, backtrace) with normalized key/value comparison and fuzzy matching support.

expect(AwesomeJob).to have_job_option(:retry, 5)
expect(AwesomeJob).to have_job_options(retry: 5, queue: "critical")

# with fuzzy matchers
expect(AwesomeJob).to have_job_options(hash_including(retry: anything))

🔍 RSpec matchers with at evaluator

🥇 @vietqhoang fixed our incompatibility through #272

RSpec matchers can now be used with the at evaluator in enqueue_sidekiq_job and have_enqueued_sidekiq_job.

expect {
  AwesomeJob.perform_at(5.minutes.from_now, "arg")
}.to enqueue_sidekiq_job(AwesomeJob).at(be_within(1.second).of(5.minutes.from_now))

☑️ on option accepts String or Symbol

🥇 @vietqhoang improved this through #273

The on option for queue matching now accepts either a String or Symbol interchangeably.

expect { AwesomeJob.perform_async }.to enqueue_sidekiq_job(AwesomeJob).on(:default)
expect { AwesomeJob.perform_async }.to enqueue_sidekiq_job(AwesomeJob).on("default")

What's Changed

  • Bump actions/checkout from 4 to 5 by @dependabot[bot] in #264
  • test: add around block to capture stdout during total method tests by @ydah in #265
  • Fix layouts by @ydah in #266
  • chore: update CI workflow to use Rake for test execution and add Rake as a development dependency by @ydah in #268
  • chore: improve formatting and consistency in README.md by @ydah in #267
  • Bump actions/checkout from 5 to 6 by @dependabot[bot] in #271
  • Support matchers with at evaluator by @vietqhoang in #272
  • Suppress warning when jobs not processed by Sidekiq in test suite by @ydah in #276
  • Allow on option to intake either a String or Symbol by @vietqhoang in #273
  • Add respond_to_missing? to NullBatch to properly support method reflection by @ydah in #275
  • Performance improvements for job matchers by @ydah in #277
  • Add have_job_option(s) matcher for job option assertions by @ydah in #278
  • Add have_job matcher and named queue stubs by @ydah in #279
  • Remove require sidekiq/testing deprecation message by @Pacyfik in #280
  • Use HTTPS for the gem homepage URL in gemspec by @ydah in #284
  • Refactor matcher count/argument logic into shared private modules by @ydah in #283
  • Raise a helpful ArgumentError when sidekiq_retries_exhausted is not defined by @ydah in #285
  • Improve test coverage for have_job matcher and named_queues by @ydah in #287
  • Fix scanning integration test to avoid Sidekiq version-specific serialization by @ydah in #289
  • Add fuzzy matcher tests for have_job_option and have_job_options by @ydah in #288
  • Fix misleading parameter name in create_active_job by @ydah in #291
  • Add Ruby 4.0 to the CI test matrix by @ydah in #290
  • Document have_job, have_job_option/options, and stub_named_queues in README by @ydah in #292
  • Suppress Sidekiq INFO logs during test suite by @ydah in #293
  • Move development dependencies from gemspec to Gemfile by @ydah in #294
  • chore: prep for release of 5.3.0 by @ydah in #295

New Contributors

Full Changelog: v5.2.0...v5.3.0

v5.2.0

19 Jul 18:17
bf4b27c

Choose a tag to compare

Welcome new co-maintainer!

Welcome @ydah as another maintainer for rspec-sidekiq. As you'll find in the changelog, @ydah has been contributing quite a bit to the health of the project to make sure even more maintainable going forward.

Thank you for joining the project!

Additions and bug-fixes

Full Changelog

  • fix spec to define sidekiq options by @wspurgin in #237
  • Update gemspec metadata to include source code and bug tracker URIs by @ydah in #249
  • Update Ruby version to 3.2.8 in .ruby-version by @ydah in #240
  • Delete the unnecessary .rubocop.yml file by @ydah in #242
  • Add spell checking GitHub Actions workflow by @ydah in #241
  • Replace pry with debug in development dependencies by @ydah in #243
  • Added dependabot for GitHub Actions by @ydah in #244
  • Remove unnecessary example RSpec configuration file by @ydah in #245
  • Change rspec command by @ydah in #246
  • Remove unnecessary dependencies by @ydah in #247
  • Use require_relative in the RSpec Sidekiq codebase by @ydah in #248
  • fix matcher to support exactly(0) by @monkeyWzr in #238
  • Add Ruby 3.4 to CI matrix in GitHub Actions workflow by @ydah in #239
  • fix: Method has a ? suffix, it returns true/false by @ydah in #261
  • Add failure test case for expecting zero job enqueues by @ydah in #255
  • Update .gitignore to include .ruby-version and remove .ruby-version file by @ydah in #252
  • fix: remove outdated GitHub link from README by @ydah in #253
  • fix: improve minus! method to return self for non-EnqueuedJobs inputs by @ydah in #254
  • Add never matcher for aliasing exactly(0) by @ydah in #256
  • chore: reorder dependencies in rspec-sidekiq.gemspec for clarity by @ydah in #257
  • chore: Changing Sidekiq version branching to use RSpec metadata by @ydah in #258
  • chore: clean up spacing and linebreak by @ydah in #259
  • chore: add CI workflow to include ruby-head by @ydah in #260
  • chore: add maintainer information for @ydah by @ydah in #262
  • chore: prep for release of 5.2.0 by @wspurgin in #263

New Contributors

Full Changelog: v5.1.0...v5.2.0

v5.1.0

07 Mar 18:58

Choose a tag to compare

Features

🎱 Sidekiq 8 Support

🙇 @jukra fixed our incompatibility through #233

with_context matcher

To add coverage for testing anything set on the Job context. Whether through something like the Current Attributes middleware or setting things directly on the Job.

expect {
  AwesomeJob.set(trace_id: "something").perform_async
}.to enqueue_sidekiq_job.with_context(trace_id: anything)

AwesomeJob.set(retry: 5).perform_async
expect(AwesomeJob).to have_enqueued_sidekiq_job.with_context(retry: 5)

# Something set through the Current Attributes middleware
expect(AwesomeJob).to have_enqueued_sidekiq_job.with_context(cattr: hash_including("my_special_attribute" => anything()))

⏲️ Sidekiq Enterprise unique until sub matcher

🙇 added in #232 by @wizardofelves (updating the original work from @leviwilson in #147)

# in e.g., AwesomeJob
sidekiq_options unique_for: 1.hour, unique_until: :start

# in spec
it { is_expected.to be_unique.until(:start) }

What's Changed

New Contributors

Full Changelog: v5.0.0...v5.1.0

v5.0.0

15 May 19:31
5becc96

Choose a tag to compare

Breaking ❗

  • have_enqueued_sidekiq_job() matches jobs with any arguments (same as enqueue_sidekiq_job() or have_enqueued_sidekiq_job(any_args)). Previously it would only match jobs with no args (#215)

New features ✨

You can now specify the number of jobs that should match the expectation! Thanks you @3v0k4 for the much requested feature!

Use via one of the following chainable methods:

  • #once
  • #twice
  • #thrice
  • #exactly(n)
  • #at_least(n)
  • #at_most(n)

Examples:

expect(AwesomeJob).to have_enqueued_sidekiq_job.once
expect(AwesomeJob).to have_enqueued_sidekiq_job.exactly(1).time
expect(AwesomeJob).to have_enqueued_sidekiq_job.exactly(:once)
expect(AwesomeJob).to have_enqueued_sidekiq_job.at_least(1).time
expect(AwesomeJob).to have_enqueued_sidekiq_job.at_least(:once)
expect(AwesomeJob).to have_enqueued_sidekiq_job.at_most(2).times
expect(AwesomeJob).to have_enqueued_sidekiq_job.at_most(:twice)
expect(AwesomeJob).to have_enqueued_sidekiq_job.at_most(:thrice)

PR Changelog

Full Changelog: v4.2.0...v5.0.0

As always, bug reports and additions are always most welcome!

v4.2.0

16 Apr 14:08

Choose a tag to compare

What's Changed

  • Fix: require matchers explicitly by @wspurgin in #214
  • Warn when using have_enqueued_sidekiq_job with no arguments for upcoming behavior change by @3v0k4 in #216 & #217

New Contributors

Full Changelog: v4.1.0...v4.2.0

v4.1.0

27 Oct 20:15

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.0.2...v4.1.0

v4.0.2

15 Aug 13:55

Choose a tag to compare

v4 - We have a release! 🚀

This repo was in ownership limbo for a few years, but now it's getting some TLC. v4 aims to squish some long standing bugs and add a few nice features we've been missing.

All feedback and bug reports are also most welcome. 😄

Summary of changes

BREAKING Changes

  • Dropped support for Rubies < 2.7
  • Dropped support for Sidekiq <5
  • Dropped support for Rails <5
  • Drop have_enqueued_job matcher
  • Mocking Sidekiq::Pro's Sidekiq::Batches is now opt-in and disabled by default

New features

Block syntax 🤙

Many examples in the README, but here's a teaser:

expect { AwesomeJob.perform_async "Awesome!" }.to enqueue_sidekiq_job(AwesomeJob).with("Awesome!")

#on chainable matcher ⛓️

Wanna test which queue your job was enqueued on? Go for it:

# Both block style and yee old have_enqueued_sidekiq_job style supports it

expect { AwesomeJob.set(queue: "high").perform_async }.to enqueue_sidekiq_job(AwesomeJob).on("high")
expect(AwesomeJob).to have_enqueued_sidekiq_job.on("high")

RSpec builtin args matchers 🙌

Finally you can use those lovely builtin Args matchers from rspec-mocks

expect {
  AwesomeJob.perform_async({ "important_arg" => true })
}.to enqueue_sidekiq_job(AwesomeJob).with(hash_including("important_arg" => boolean))

# or using the non-block style
expect(AwesomeJob).to have_enqueued_sidekiq_job(hash_including("important_arg" => boolean))

PR list

Many other bug fixes, and enhancements have gone into v4 as well. Here's all the PRs.

v4.0.1

  • Restore normalizing args to fix unintentional breaking change with symbols #205

v4.0.2

  • Explicitly require forwardable #204

New Contributors

Full Changelog: v3.1.0...v4.0.2

4.0.0.pre

09 Aug 20:23

Choose a tag to compare

4.0.0.pre Pre-release
Pre-release

v4.0.0.pre - We have a (pre)release! 🚀

What needs testing in the wild

I personally don't use ActiveJob basically at all in any project where I use Sidekiq. This is mostly just from longstanding habit since Sidekiq 5 and the known performance drops one encountered when using ActiveJob as a middle-man.

As such, I don't have a place to play around with how testing ActiveJob with v4 works (or doesn't!). If anyone uses ActiveJob with Sidekiq and uses this repo for testing your Sidekiq-ery, please give this prerelease a try and send in issues and feedback.

For all other plain-ol' Sidekiq users, your feedback and bug reports are also most welcome. 😄

v3.1.0

21 Jun 16:26

Choose a tag to compare

3.1.0

  • Add support for latest ruby and Rails 5 (coding-bunny #156)
  • Support Class#method notation in batch callback (caalberts #155)
  • Fix bug with time comparison in delayed jobs (geeosh #153 with help from col)
  • remove usage of Integer#blank? (lanej #152)
  • Add NullBatch#description (dsantosmerino #139)
  • README updates (BenMusch #142, akihikodaki #141, wpolicarpo #160)

3.0.3

21 Jun 15:40

Choose a tag to compare

Tick to 3.0.3

Also includes changes from CHANGES.md for 3.0.2, which were forgotten