module ActionMailbox::TestHelper

def create_inbound_email_from_fixture(fixture_name, status: :processing)

referenced with +fixture_name+ located in +test/fixtures/files/fixture_name+.
Create an +InboundEmail+ record using an eml fixture in the format of message/rfc822
def create_inbound_email_from_fixture(fixture_name, status: :processing)
  create_inbound_email_from_source file_fixture(fixture_name).read, status: status
end

def create_inbound_email_from_mail(status: :processing, **mail_options)

create_inbound_email_from_mail(from: "david@loudthinking.com", subject: "Hello!")

Create an +InboundEmail+ by specifying it using +Mail.new+ options. Example:
def create_inbound_email_from_mail(status: :processing, **mail_options)
  mail = Mail.new(mail_options)
  # Bcc header is not encoded by default
  mail[:bcc].include_in_headers = true if mail[:bcc]
  create_inbound_email_from_source mail.to_s, status: status
end

def create_inbound_email_from_source(source, status: :processing)

Create an +InboundEmail+ using the raw rfc822 +source+ as text.
def create_inbound_email_from_source(source, status: :processing)
  ActionMailbox::InboundEmail.create_and_extract_message_id! source, status: status
end

def receive_inbound_email_from_fixture(*args)

and immediately route it to processing.
Create an +InboundEmail+ from fixture using the same arguments as +create_inbound_email_from_fixture+
def receive_inbound_email_from_fixture(*args)
  create_inbound_email_from_fixture(*args).tap(&:route)
end

def receive_inbound_email_from_mail(**kwargs)

processing.
Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_mail+ and immediately route it to
def receive_inbound_email_from_mail(**kwargs)
  create_inbound_email_from_mail(**kwargs).tap(&:route)
end

def receive_inbound_email_from_source(*args)

to processing.
Create an +InboundEmail+ using the same arguments as +create_inbound_email_from_source+ and immediately route it
def receive_inbound_email_from_source(*args)
  create_inbound_email_from_source(*args).tap(&:route)
end