Skip to content

Latest commit

 

History

History
75 lines (54 loc) · 2.98 KB

README.md

File metadata and controls

75 lines (54 loc) · 2.98 KB

Test views, be true! :)

Build Status

Mikhalok

Why?

  • you need to test some complex views
  • and you want to use rspec2
  • and assert_select seems is something strange to you
  • have_tag in rspec-rails are deprecated now
  • you need user-firendly output in error messages

Being true

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

additional list of defined matchers ("form" matchers)

and of course you can use without_matchers

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.

Contribution

  1. fork
  2. add tests for feature
  3. write implementation
  4. send pull request

Contributors