Skip to content

Commit 603b901

Browse files
committed
Add section for testing negative case
Update link for warning message
1 parent 4e8b5d7 commit 603b901

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ AwesomeJob.set(queue: "high").perform_async("Very Awesome!")
102102
expect(AwesomeJob).to have_enqueued_sidekiq_job("Very Awesome!").on("high")
103103
```
104104

105-
106105
#### Testing ActiveMailer jobs
107106

108107
```ruby
@@ -118,6 +117,25 @@ expect(Sidekiq::Worker).to have_enqueued_sidekiq_job(
118117
)
119118
```
120119

120+
#### Testing a job is _not_ enqueued
121+
122+
The negative case for `have_enqueued_sidekiq_job` is provided, but it's
123+
important to remember that `have_enqueued_sidekiq_job` is an expectation of
124+
specific _arguments_. That means, unless you tell the matcher that _no_ jobs
125+
with _any_ arguments should be enqueued, you'll get the wrong result:
126+
127+
```ruby
128+
# failing case
129+
AwesomeJob.perform_async "Actually not awesome"
130+
131+
### BAD - saying there shouldn't be a job enqueued _without_ args
132+
expect(AwesomeJob).not_to have_enqueued_sidekiq_job
133+
# => passes! 😱
134+
135+
### Good
136+
expect(AwesomeJob).not_to have_enqueued_sidekiq_job(any_args)
137+
```
138+
121139
### be_processed_in
122140
*Describes the queue that a job should be processed in*
123141
```ruby

lib/rspec/sidekiq/sidekiq.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def configuration
1414

1515
RSpec.configure do |config|
1616
config.before(:suite) do
17-
message = '[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See https://github.com/philostler/rspec-sidekiq/wiki/FAQ-&-Troubleshooting'
17+
message = '[rspec-sidekiq] WARNING! Sidekiq will *NOT* process jobs in this environment. See https://github.com/wspurgin/rspec-sidekiq/wiki/FAQ-&-Troubleshooting'
1818
message = "\e[33m#{message}\e[0m" if RSpec::Sidekiq.configuration.enable_terminal_colours
1919
puts message if RSpec::Sidekiq.configuration.warn_when_jobs_not_processed_by_sidekiq
2020
end

0 commit comments

Comments
 (0)