Skip to content

Commit

Permalink
Use mailbox_for when available
Browse files Browse the repository at this point in the history
  • Loading branch information
benoittgt committed Dec 2, 2020
1 parent ff94e1b commit 7300e06
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/rspec/rails/matchers/action_mailbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,20 @@ def initialize(message)
@inbound_email = create_inbound_email(message)
end

def matches?(mailbox)
@mailbox = mailbox
@receiver = ApplicationMailbox.router.send(:match_to_mailbox, inbound_email)
if defined?(::ApplicationMailbox) && ::ApplicationMailbox.router.respond_to?(:mailbox_for)
def matches?(mailbox)
@mailbox = mailbox
@receiver = ApplicationMailbox.router.mailbox_for(inbound_email)

@receiver == @mailbox
@receiver == @mailbox
end
else
def matches?(mailbox)
@mailbox = mailbox
@receiver = ApplicationMailbox.router.send(:match_to_mailbox, inbound_email)

@receiver == @mailbox
end
end

def failure_message
Expand All @@ -41,7 +50,7 @@ def failure_message_when_negated
"expected #{describe_inbound_email} not to route to #{mailbox}"
end

private
private

attr_reader :inbound_email, :mailbox, :receiver

Expand Down

0 comments on commit 7300e06

Please sign in to comment.