Semantic rspec view matchers with rspec-html-matcher gem

21:45 , , , 0 Comments

Lately I've been concerned about writing specs for rails views and I came across the rspec-html-matchers gem.

I won't repeat the documentation here but the idea is quite simple.
Render your view using rspec and then match it using something sweet like:

render
rendered.should have_tag(:form) do
  with_tag :input, :with => { :name => "foo"}
end

It's much quicker and efficient than parsing the html yourself using nokogiri for example.

0 comments: