Hello everyone,
A few weeks ago, I put together a little project that provides a
have_tag() matcher look-alike that can be used outside of Rails
projects, backed by Hpricot, which I very creatively named
rspec_hpricot_matchers. It’s not a drop-in replacement for
rspec_on_rails’ have_tag(): no substitution values, Hpricot’s CSS
selectors aren’t identical to assert_select’s, and with_tag() has been
replaced by nested calls to have_tag(). But it’s pretty close and even
enjoys a few benefits over the standard implementation.
I finally got around to registering a project on RubyForge and pushing
a gem, so it is now available with just:
gem install rspec_hpricot_matchers
If you’re interested, the source is hosted on github at:
GitHub - pd/rspec_hpricot_matchers: have_tag() without Rails' assert_select()
I’m using this both in isolated XML-related libraries and in my Rails
projects, and I haven’t come up with any features I want lately, so
it’s reasonably stable in my experience. Usage examples are available
in the README, and the specs are simple enough to be another good set
of examples.
Suggestions, patches and angry flames about list spamming are all
welcome.
Thanks
Kyle