I ran into a small problem using assert_select_email -- it expects multipart messages, and those we are sending are not.
A quick and dirty solution was to included the following ugly monkeypatch rewrite of the SelectorAssertions in our test_helper file:
module ActionController
module Assertions
module SelectorAssertions
def assert_select_email(&block)
deliveries = ActionMailer::Base.deliveries
assert(!deliveries.empty?, "No e-mail in delivery list")
for delivery in deliveries
for part in delivery.parts.empty? ? [delivery] : delivery.parts.select{|p| p["Content-Type"].to_s =~ /^text\/html\W/}
root = HTML::Document.new(part.body).root
assert_select(root, ":root", &block)
end
end
end
end
end
end
Comments