123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Rails::MailboxExampleGroup

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActionMailbox::TestHelper, ActiveSupport::Concern
Defined in: rspec-rails/lib/rspec/rails/example/mailbox_example_group.rb

Overview

Container module for mailbox spec functionality.

Class Method Summary

Instance Method Summary

DSL Calls

included

[ GitHub ]


34
35
36
# File 'rspec-rails/lib/rspec/rails/example/mailbox_example_group.rb', line 34

included do
  subject { described_class }
end

Class Method Details

.create_inbound_email(_arg)

This method is for internal use only.

See additional method definition at line 13.

[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/example/mailbox_example_group.rb', line 22

def self.create_inbound_email(arg)
  case arg
  when Hash
    create_inbound_email_from_mail(**arg)
  else
    create_inbound_email_from_source(arg.to_s)
  end
end

Instance Method Details

#have_been_delivered

Passes if the inbound email was delivered

Examples:

inbound_email = process(args)
expect(inbound_email).to have_been_delivered
[ GitHub ]

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

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

#have_bounced

Passes if the inbound email bounced during processing

Examples:

inbound_email = process(args)
expect(inbound_email).to have_bounced
[ GitHub ]

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

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

#have_failed

Passes if the inbound email failed to process

Examples:

inbound_email = process(args)
expect(inbound_email).to have_failed
[ GitHub ]

  
# File 'rspec-rails/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

[ GitHub ]

  
# File 'rspec-rails/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