module EmailSpectacular::RSpec

Module containing email helper methods that can be mixed into the RSpec test scope

@author Aleck Greenham

Public Instance Methods

have_been_enqueued() click to toggle source

Creates a new email expectation that allows asserting emails should have specific attributes, applied only to emails that have been enqueued to be sent.

@see EmailSpectacular::Expectation

@example Asserting email has been enqueued

expect(email).to have_been_enqueued.to('test@email.com')
# File lib/email_spectacular/rspec.rb, line 32
def have_been_enqueued # rubocop:disable Naming/PredicateName
  unless EmailSpectacular._mocking_sending_enqueued_emails
    raise 'EmailSpectacular: Cannot use the have_been_enqueued assertion without setting the ' \
          'mock_sending_enqueued_emails configuration option.'
  end

  EmailSpectacular::RSpecMatcher.new(enqueued: true)
end
have_been_sent() click to toggle source

Creates a new email expectation that allows asserting emails should have specific attributes, applied only to send emails.

@see EmailSpectacular::Expectation

@example Asserting email has been sent

expect(email).to have_been_sent.to('test@email.com')
# File lib/email_spectacular/rspec.rb, line 21
def have_been_sent # rubocop:disable Naming/PredicateName
  EmailSpectacular::RSpecMatcher.new(enqueued: false)
end