method
assert_enqueued_email_with
v6.0.0 -
Show latest stable
-
0 notes -
Class: ActionMailer::TestHelper
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1
- 5.1.7
- 5.2.3 (0)
- 6.0.0 (10)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (38)
- 7.1.3.4 (0)
- What's this?
assert_enqueued_email_with(mailer, method, args: nil, queue: "mailers", &block)
public
Asserts that a specific email has been enqueued, optionally matching arguments.
def test_email ContactMailer.welcome.deliver_later assert_enqueued_email_with ContactMailer, :welcome end def test_email_with_arguments ContactMailer.welcome("Hello", "Goodbye").deliver_later assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"] end
If a block is passed, that block should cause the specified email to be enqueued.
def test_email_in_block assert_enqueued_email_with ContactMailer, :welcome do ContactMailer.welcome.deliver_later end end
If args is provided as a Hash, a parameterized email is matched.
def test_parameterized_email assert_enqueued_email_with ContactMailer, :welcome, args: {email: 'user@example.com'} do ContactMailer.with(email: 'user@example.com').welcome.deliver_later end end