require 'abstract_unit' class AssertSelectEmailTest < ActionMailer::TestCase class AssertSelectMailer < ActionMailer::Base def test(html) mail body: html, content_type: "text/html", subject: "Test e-mail", from: "test@test.host", to: "test " end end class AssertMultipartSelectMailer < ActionMailer::Base def test(options) mail subject: "Test e-mail", from: "test@test.host", to: "test " do |format| format.text { render text: options[:text] } format.html { render text: options[:html] } end end end # # Test assert_select_email # def test_assert_select_email assert_raise ActiveSupport::TestCase::Assertion do assert_select_email {} end AssertSelectMailer.test("

foo

bar

").deliver assert_select_email do assert_select "div:root" do assert_select "p:first-child", "foo" assert_select "p:last-child", "bar" end end end def test_assert_select_email_multipart AssertMultipartSelectMailer.test(html: "

foo

bar

", text: 'foo bar').deliver assert_select_email do assert_select "div:root" do assert_select "p:first-child", "foo" assert_select "p:last-child", "bar" end end end end