Nokogiri based have_tag, with_tag matchers for rspec 2
Switch branches/tags
Pull request Compare This branch is 255 commits behind kucaahbe:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
docs
lib
spec
.gitignore
.rspec
.yardopts
Gemfile
Gemfile.lock
README.md
Rakefile
rspec2-rails-views-matchers.gemspec

README.md

Test views, be true! :)

Mikhalok

(Lyapis Trubetskoy)

Why?

  • you need to test some complex views
  • and you want to use rspec2
  • and assert_select seems is something strange to you
  • rspec-rails for some reason does not provide instruments for testing views
  • you need user-firendly output in error messages

Install

add to your Gemfile(in group :test :) ):

gem 'rspec2-rails-views-matchers'

Usage

some examples:

rendered.should have_tag('form',:with => {:action => user_path, :method => 'post'}) do
  with_tag "input", :with => { :name => "user[email]",    :type => 'email' }
  with_tag "input#special_submit", :count => 1
  without_tag "h1", :text => 'unneeded tag'
  without_tag "p",  :text => /content/i
end

More info

You can find on RubyDoc, take a look at {RSpec::Matchers#have_tag have_tag} method.

Also, please read {file:docs/CHANGELOG.md CHANGELOG}, it might be helpful.