Skip to content
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

Feature request: have_enqueued_email matcher to deal with ActionMailer::DeliveryJob #1901

Closed
fabn opened this issue Oct 27, 2017 · 6 comments

Comments

@fabn
Copy link
Contributor

fabn commented Oct 27, 2017

I use a lot the have_enqueued_job matcher because I like its syntax and it also perform params serialization that allows me to catch invalid arguments given to background jobs such as symbol serialization.

However I think that it's a little bit too verbose when used with ActionMailer::DeliveryJob e.g.

expect {
  subject.perform request
}.to have_enqueued_job(ActionMailer::DeliveryJob).with(
    'SubscriptionMailer',
    'welcome',
    'deliver_now',
    hash_including('email_address' => email),
    'en'
)

It would be very nice to have a specialized wrapper around it, something like this

expect {
  subject.perform request
}.to have_enqueued_email(SubscriptionMailer, :welcome).with(hash_including('email_address' => email), 'en')

What do you think?

@JonRowe
Copy link
Member

JonRowe commented Oct 29, 2017

This sounds like the perfect excuse to write a little extension gem

@jdlubrano
Copy link
Contributor

Hey, not sure if this is helpful or too late, but I have made gem that provides a matcher for deliver_later. The gem is called deliver_later_matchers.

GitHub: https://github.com/jdlubrano/deliver_later_matchers
Rubygems: https://rubygems.org/gems/deliver_later_matchers

@benoittgt
Copy link
Member

benoittgt commented Dec 7, 2018

This can be done with a matcher. Please look at #1849 (comment)

@JonRowe do you think we should close this issue?

@JonRowe
Copy link
Member

JonRowe commented Dec 7, 2018

No, I feel as we have enqueued job matchers, and ActiveMailer uses active job, this is something we should consider, @jdlubrano would you care to submit a PR with your changes rolled into ours?

@jdlubrano
Copy link
Contributor

jdlubrano commented Dec 7, 2018

@JonRowe

Thank you for reaching out; I would be delighted to submit a PR. Have you had a chance to look at the deliver_later_matchers gem's API? Do you want to use the same API in rspec-rails or did you have something else in mind?

@JonRowe
Copy link
Member

JonRowe commented Dec 7, 2018

Yes I have, it looks very similar to our job matchers on the outside and inside, it would be great to leverage our existing job innards if possible (legitimate case for inheritance woo!)

Personally I would make have_enqueued_mail the primary interface, and have the other two as aliases as you wish :)

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

No branches or pull requests

4 participants