Simple Rspec Markup Matcher

Posted October 1st, 2008; 0 comments.

It seems like every project I’ve worked on recently involves some kind of markup processing. Here’s what I’ve been using to test my markup processing:

This matcher does two things that are helpful. It standardizes the order of attributes, which is crucial since most of the time HTML attributes are specified in Ruby using a hash and therefore their eventual order can’t be guaranteed. It also removes all whitespace, so your specs can be easier on you.

Here’s a totally contrived example:

I’m trying out using Gist to post code to the site- it conveniently matches the color scheme.

Leave a Reply