-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
What Ruby, Rails and RSpec versions are you using?
Ruby version: 3.3.4
Rails version: 7.2.1
RSpec version: 3.13.0
RSpec-rails version: 7.0.1
Observed behaviour
When using expect { <code> }.to have_enqueued_email
it also counts any other enqueued jobs (that are not emails).
I think this only happens when not specifying mailer class and method.
This has happened in an upgrade from rspec-rails 6.1.4
to rspec-rails 7.0.1
. I beleive this commit is the reason, since the overwritten method job_match?
in HaveEnqueuedMail
is no longer called. It was renamed to job_matches?
in the ActiveJob::HaveEnqueuedJob
superclass.
Expected behaviour
It should only count emails and not other jobs.
Can you provide an example reproduction?
We have a shared example that asserts that exactly one email is enqueued:
RSpec.shared_examples "an email sending command" do
it "does not enqueue additional emails if invoked twice" do
expect {
described_class.run(inputs)
described_class.run(inputs)
}.to have_enqueued_mail.at_most(:once)
end
end
When that code also enqueues other ActiveJobs, this wrongly counts as two emails.
Metadata
Metadata
Assignees
Labels
No labels