Module: RSpec::Rails::MailboxExampleGroup

Extended by:
ActionMailbox::TestHelper, ActiveSupport::Concern
Defined in:
lib/rspec/rails/example/mailbox_example_group.rb

Overview

Container module for mailbox spec functionality.

Instance Method Summary collapse

Instance Method Details

#have_been_deliveredObject

Passes if the inbound email was delivered

Examples:

inbound_email = process(args)
expect(inbound_email).to have_been_delivered


44
45
46
# File 'lib/rspec/rails/example/mailbox_example_group.rb', line 44

def have_been_delivered
  satisfy('have been delivered', &:delivered?)
end

#have_bouncedObject

Passes if the inbound email bounced during processing

Examples:

inbound_email = process(args)
expect(inbound_email).to have_bounced


54
55
56
# File 'lib/rspec/rails/example/mailbox_example_group.rb', line 54

def have_bounced
  satisfy('have bounced', &:bounced?)
end

#have_failedObject

Passes if the inbound email failed to process

Examples:

inbound_email = process(args)
expect(inbound_email).to have_failed


64
65
66
# File 'lib/rspec/rails/example/mailbox_example_group.rb', line 64

def have_failed
  satisfy('have failed', &:failed?)
end

#process(message) ⇒ ActionMailbox::InboundMessage

Process an inbound email message directly, bypassing routing.

Parameters:

  • message (Hash, Mail::Message)

    a mail message or hash of attributes used to build one

Returns:

  • (ActionMailbox::InboundMessage)


73
74
75
76
77
# File 'lib/rspec/rails/example/mailbox_example_group.rb', line 73

def process(message)
  MailboxExampleGroup.create_inbound_email(message).tap do |mail|
    self.class.mailbox_class.receive(mail)
  end
end