Module: Shoulda::ActionMailer::Matchers

Included in:
ActiveSupport::TestCase, RSpec::Rails::MailerExampleGroup, Test::Unit::TestCase, Test::Unit::TestCase
Defined in:
lib/shoulda/action_mailer/matchers.rb,
lib/shoulda/action_mailer/matchers/have_sent_email.rb

Overview

Matchers for your mailers

This matcher will test that email is sent properly

describe User do
  it { should have_sent_email.with_subject(/is spam$/) }
  it { should have_sent_email.from('[email protected]') }
  it { should have_sent_email.with_body(/is spam\./) }
  it { should have_sent_email.to('[email protected]') }
  it { should have_sent_email.with_subject(/spam/).
                              from('[email protected]').
                              with_body(/spam/).
                              to('[email protected]') }
end

Defined Under Namespace

Classes: HaveSentEmailMatcher

Instance Method Summary collapse

Instance Method Details

#have_sent_emailObject

The right email is sent.

it { should have_sent_email.with_subject(/is spam$/) }
it { should have_sent_email.from('[email protected]') }
it { should have_sent_email.with_body(/is spam\./) }
it { should have_sent_email.to('[email protected]') }
it { should have_sent_email.with_subject(/spam/).
                            from('[email protected]').
                            with_body(/spam/).
                            to('[email protected]') }

15
16
17
# File 'lib/shoulda/action_mailer/matchers/have_sent_email.rb', line 15

def have_sent_email
  HaveSentEmailMatcher.new
end