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

I send my mail both via Pony and ActionMailer #216

Open
AndreyKorol opened this issue Oct 18, 2019 · 0 comments
Open

I send my mail both via Pony and ActionMailer #216

AndreyKorol opened this issue Oct 18, 2019 · 0 comments

Comments

@AndreyKorol
Copy link

I send my mail both via Pony and ActionMailer. When i want to test ActionMailer i can't, because email-spec defines deliveries method only in Pony way.
Can you add possibility to choose mail service i work through?

module Deliveries
  if defined?(Pony)
    def deliveries; Pony::deliveries ; end
    include EmailSpec::MailerDeliveries
  elsif ActionMailer::Base.delivery_method == :activerecord
    include EmailSpec::ARMailerDeliveries
  else
    def mailer; ActionMailer::Base; end
    include EmailSpec::MailerDeliveries
  end
end
cgunther added a commit to cgunther/email-spec that referenced this issue Jun 21, 2023
After email-spec#219, ActionMailer became lazily loaded, leading to this library
hooking into RSpec potentially before including the module specific to
the delivery method in use, so RSpec never saw the delivery
method-specific module, leading to errors as documented in email-spec#221.

Now, the individual methods (ie. `reset_mailer`, `deliveries`) are
responsible for branching based on the correct delivery method, defining
their corresponding implementation.

Thinking longer term, there's no guarantee a single delivery method is
used across the board (though that's likely the most common scenario),
so rather than branching, we should probably iterate through all
supported delivery methods. email-spec#216 touches on this, where instead of
assuming Pony OR ActionMailer, both should likely be supported
simultaneously, searching each for a given email, and resetting all.

Fixes email-spec#221
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

1 participant