[Ruby] Rails view testing questions

Laurel Fan laurel.fan at gmail.com
Thu Sep 21 10:33:12 PDT 2006


On 9/21/06, Joe Van Dyk <joevandyk at gmail.com> wrote:
> Would be also handy if the view tests could incorporate
> assert_valid_markup or assert_valid_asset somehow.

I've made a small change to fail the test when the html parser can't
parse the html:

class Test::Rails::ViewTestCase
  def html_document
      @html_document ||= HTML::Document.new(@response.body, true)
  end
end

(basically the second arg to HTML::Document.new says to throw an
exception when parsing fails).  It doesn't catch everything (like it
doesn't care if you have a <td> that's not in a <tr>), but it does
catch obvious things like mismatched open/close tags.

-- 
Laurel Fan
http://blog.gorgorg.org


More information about the Ruby mailing list