I’ve been using for Rails apps I’ve been maintaining the hpricot_matchers and most recently rspec_tag_matchers as matcher implementations to test strings with nested tags inside (like, let’s say, HTML or XML). Specially the last one is really good, since it uses Nokogiri.
Recently I started developing in Sinatra, and of course, I bundled rspec in it. All is nice and neat, til I found out I don’t have certain matchers available like the have_tag (which check tags and attributes values). Well, this would be really great to have in Sinatra, and the above mentioned gems are not usable, since they have a rspec-rails dependency, which has a rails dependency.
So the question would be: is there any tool available for Sinatra which accomplishes the same task? Any Sinatra matchers out in the open? Couldn’t find any, though.
Actually found out an extension that does the job…
https://github.com/kucaahbe/rspec-html-matchers
Should have looked a little bit more. I haven’t checked whether it covers everything that the rails rspec matcher helpers do, but most of the important ones are there, including the very valuable have_tag. One thing, though: the specification for both is a bit different when it comes to nested conditions in sub-tags:
rspec_tag_matchers(rails3):
rspec_html_matchers(sinatra/…):