Skip to content

Make sure that negative matcher fails on multiple enqueues of the same kind #1871

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

Conversation

povilasjurcys
Copy link

Fix for #1870.

Without this fix test passes for given example

expect {
  job.perform_later
  job.perform_later
}.not_to have_enqueued_job

This happens because by default we check using options :exactly, 1. That is, under the hood
}.not_to have_enqueued_job
is same as
.not_to have_enqueued_job.exactly(:once).

In negative examples this is incorrect - we should use :exaclty, 0 instead.
Negative example
.not_to have_enqueued_job
should be equal to positive example with conditions
.to have_enqueued_job.exactly(0)

@fables-tales
Copy link
Member

can you provide full examples of what the various kinds of error messages look like when this matcher fails?

@povilasjurcys
Copy link
Author

@samphippen did you had something like this in mind: 38801ac

@pirj
Copy link
Member

pirj commented Dec 11, 2019

This is pretty much covered in #2069
Please feel free to reopen if you're up to improve current failure messages.

In general, the use of quantitive qualifiers with negated version of those matchers reads weird.

@pirj pirj closed this Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants