class RSpec::Rails::Matchers::ActionMailbox::ReceiveInboundEmail

@private

def describe_inbound_email

def describe_inbound_email
  "mail to #{inbound_email.mail.to.to_sentence}"
end

def failure_message

def failure_message
  "expected #{describe_inbound_email} to route to #{mailbox}".tap do |msg|
    if receiver
      msg << ", but routed to #{receiver} instead"
    end
  end
end

def failure_message_when_negated

def failure_message_when_negated
  "expected #{describe_inbound_email} not to route to #{mailbox}"
end

def initialize(message)

def initialize(message)
  super()
  @inbound_email = create_inbound_email(message)
end

def matches?(mailbox)

def matches?(mailbox)
  @mailbox  = mailbox
  @receiver = ApplicationMailbox.router.mailbox_for(inbound_email)
  @receiver == @mailbox
end

def matches?(mailbox)

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