Skip to content

Commit f1b4a20

Browse files
authored
deprecate have_enqueued_sidekiq_job with no arguments (#216)
1 parent 0e710d7 commit f1b4a20

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Unreleased
2+
---
3+
* Deprecate `have_enqueued_sidekiq_job` with no arguments (use either `have_enqueued_sidekiq_job(no_args)` or `have_enqueued_sidekiq_job(any_args)`) ([@3v0k4](https://github.com/3v0k4))
4+
15
4.1.0
26
---
37
* Add Composable support to `enqueue_sidekiq_job` and

lib/rspec/sidekiq/matchers/have_enqueued_sidekiq_job.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ def have_enqueued_sidekiq_job(*expected_arguments)
77

88
# @api private
99
class HaveEnqueuedSidekiqJob < Base
10+
DEPRECATION = [
11+
"[DEPRECATION] `have_enqueued_sidekiq_job()` is deprecated.",
12+
"Please use either `have_enqueued_sidekiq_job(no_args)` or `have_enqueued_sidekiq_job(any_args)`."
13+
].join(" ")
14+
1015
def initialize(expected_arguments)
1116
super()
1217
@expected_arguments = normalize_arguments(expected_arguments)
@@ -17,6 +22,7 @@ def matches?(job_class)
1722

1823
@actual_jobs = EnqueuedJobs.new(klass)
1924

25+
warn DEPRECATION if expected_arguments == []
2026
actual_jobs.includes?(expected_arguments, expected_options)
2127
end
2228
end

spec/rspec/sidekiq/matchers/have_enqueued_sidekiq_job_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
expect(worker).to have_enqueued_sidekiq_job *worker_args
2424
end
2525

26+
it 'matches with no arguments but prints a warning' do
27+
worker.perform_async
28+
expect {
29+
expect(worker).to have_enqueued_sidekiq_job
30+
}.to output(/[DEPRECATION]/).to_stderr
31+
end
32+
33+
it 'matches with no_args' do
34+
worker.perform_async
35+
expect(worker).to have_enqueued_sidekiq_job(no_args)
36+
end
37+
2638
it 'matches on the global Worker queue' do
2739
worker.perform_async *worker_args
2840
expect(Sidekiq::Worker).to have_enqueued_sidekiq_job *worker_args

0 commit comments

Comments
 (0)