Deirdre Saoirse Moen

Sounds Like Weird

Validating Markup in Functional Tests

01 November 2005

Occasionally, one finds little gems in patches rejected for inclusion into Rails. This is one of those gems.

You can take the code, plop it into your test/testhelper.rb, add an “assertvalid_markup” to the right functional test and then it’ll tell you exactly how borked your (x)html is, complete with all relevant error messages.

Note: I recommend commenting that out after you’ve gotten valid markup and only check when you’ve made major changes to the markup or are about to deploy. That way, your testing will go much faster and you won’t slam the w3c’s servers.

Thanks to Scott Raymond.

Since putting the code here broke my layout (and my mother complained about that), get the info from the Rails wiki page.

Related Posts