You can use the
assert_select_email
or the usual assert_select
methods.
I prefer the second option, and my code looks like (Rails 3.0.X)email = ActionMailer::Base.deliveries.last body = email.html_part.decoded
node = HTML::Document.new(body).root assert_select node, ':root' do #do your assertions here end
It took me, however, some time to fix the error
NoMethodError: undefined method `assert_select' for
In Rails 3.0.X it is as easy as including the appropriate module (within you test class)
include ActionDispatch::Assertions::SelectorAssertions
For newer rails versions check the official guide of teh the assert_select method, and check which module is it defined in.
No comments:
Post a Comment