Skip to content

expect { }.to have_enqueued_mail().with() doesn't work with ActionMailer::MailDeliveryJob #2184

Closed
@simmerz

Description

@simmerz

What Ruby, Rails and RSpec versions are you using?

Ruby version: 2.5.1
Rails version: 6.0.0
RSpec version: branch 4-0-dev

Observed behaviour

Given an email enqueued with:

SomeMailer.with(object: foo, option: { amended: true }).some_method.deliver_later

I would expect the following to pass:

expect { some_action_which_enqueues_mail }.to have_enqueued_mail(SomeMailer, :some_method).with(object: foo, option: { amended: true })

It doesn't pass when setting the default delivery job to ActionMailer::MailDeliveryJob but does when using the legacy ActionMailer::Parameterized::DeliveryJob (ie. config.load_defaults 5.2 and Rails.application.config.action_mailer.delivery_job = 'ActionMailer::MailDeliveryJob' commented out in config/initializers/new_framework_defaults_6_0.rb

The listed enqueued mails shows the mail has been enqueued, but I cannot seem to access it with my test criteria.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions