-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Negative have_enqueued_job
does not work as expected with multiple jobs of same kind
#1870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure what you're asking here, it seems your code snippet should fail, as Are you saying it passes? Because thats a bug. |
I'm saying that |
I faced same issue. You can hack it with: expect{ my_job.perform }.to have_enqueued_job(OtherJob).exactly(0).times |
Here is my proof of concept:
As I understand,
have_enqueued_job
checks if job was performed exactly once, soexpect { my_job.perform }.to have_enqueued_job(OtherJob)
is same asexpect { my_job.perform }.to have_enqueued_job(OtherJob).exactly(:once)
.But in negative case
expect { my_job.perform }.not_to have_enqueued_job(OtherJob)
becomes same asexpect { my_job.perform }.not_to have_enqueued_job(OtherJob).exactly(:once)
. So it's quite clear whyexpect { my_job.perform }.not_to have_enqueued_job(OtherJob)
returns true when there is multiple jobs of same kind, but behavior is confusing.Tried with rspec-rails 3.6.1.
The text was updated successfully, but these errors were encountered: