Swoosh v0.21.0 Swoosh.TestAssertions View Source
This module contains a set of assertions functions that you can import in your test cases.
It is meant to be used with the Swoosh.Adapters.Test module.
Link to this section Summary
Functions
Asserts email
was not sent
Asserts any email was sent
Asserts email
was sent
Asserts no emails were sent
Asserts no emails were sent
Asserts email with attributes
was not sent
Link to this section Functions
assert_email_not_sent(email)
View Source
assert_email_not_sent(Swoosh.Email.t()) :: false | no_return()
assert_email_not_sent(Swoosh.Email.t()) :: false | no_return()
Asserts email
was not sent.
Performs exact matching of the email struct.
assert_email_sent()
View Source
assert_email_sent() :: true | no_return()
assert_email_sent() :: true | no_return()
Asserts any email was sent.
assert_email_sent(email)
View Source
assert_email_sent(Swoosh.Email.t() | Keyword.t()) :: true | no_return()
assert_email_sent(Swoosh.Email.t() | Keyword.t()) :: true | no_return()
Asserts email
was sent.
You pass a keyword list to match on specific params.
Examples
iex> alias Swoosh.Email
iex> import Swoosh.TestAssertions
iex> email = Email.new(subject: "Hello, Avengers!")
iex> Swoosh.Adapters.Test.deliver(email, [])
# assert a specific email was sent
iex> assert_email_sent email
# assert an email with specific field(s) was sent
iex> assert_email_sent subject: "Hello, Avengers!"
assert_no_email_sent()
View Source
assert_no_email_sent() :: false | no_return()
assert_no_email_sent() :: false | no_return()
Asserts no emails were sent.
refute_email_sent() View Source (macro)
Asserts no emails were sent.
refute_email_sent(attributes) View Source (macro)
Asserts email with attributes
was not sent.
Performs pattern matching using the given pattern, equivalent to pattern = email
.
When a list of attributes is given, they will be converted to a pattern.
It converts list fields (:to
, :cc
, :bcc
) to a single element list if a single value is
given (to: "email@example.com"
=> to: ["email@example.com"]
).
After conversion, performs pattern matching using a map of email attributes, similar to
%{attributes...} = email
.