assert_select_email

assert_select_email(&block)
Instance Public methods

Extracts the body of an email and runs nested assertions on it.

You must enable deliveries for this assertion to work, use:

1
2
3
4
5
6
7
8
9
10
11
12
ActionMailer::Base.perform_deliveries = true
 
assert_select_email do
  assert_select "h1", "Email alert"
end
 
assert_select_email do
  items = assert_select "ol>li"
  items.each do
     # Work with items here...
  end
end
doc_ruby_on_rails
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.