module Rails::Dom::Testing::Assertions::SelectorAssertions

def assert_dom_email(html_version: nil, &block)


end
assert_dom "h1", "Email alert"
assert_dom_email(html_version: :html5) do

html_version: :html4 or html_version: :html5 keyword arguments:
If you want to specify the HTML parser just for a particular assertion, pass

+Rails.application.config.dom_testing_default_html_version+.
When testing in a Rails application, the parser default can also be set by setting

Rails::Dom::Testing.default_html_version (either :html4 or :html5).
The DOM is created using an HTML parser specified by

end
end
# Work with items here...
items.each do
items = assert_dom "ol>li"
assert_dom_email do

end
assert_dom "h1", "Email alert"
assert_dom_email do

Example usage:

ActionMailer::Base.perform_deliveries = true
You must enable deliveries for this assertion to work, use:

Extracts the body of an email and runs nested assertions on it.
def assert_dom_email(html_version: nil, &block)
  deliveries = ActionMailer::Base.deliveries
  assert !deliveries.empty?, "No e-mail in delivery list"
  deliveries.each do |delivery|
    (delivery.parts.empty? ? [delivery] : delivery.parts).each do |part|
      if /^text\/html\W/.match?(part["Content-Type"].to_s)
        root = Rails::Dom::Testing.html_document_fragment(html_version: html_version).parse(part.body.to_s)
        assert_dom root, ":root", &block
      end
    end
  end
end