- 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
add to your Gemfile(in group :test :) ):
gem 'rspec2-rails-views-matchers'
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
- have_form
- with_checkbox
- with_file_field
- with_hidden_field
- with_option
- with_password_field
- with_radio_button
- with_select
- with_submit
- with_text_area
- with_text_field
and of course you can use without_matchers
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.
- fork
- add tests for feature
- write implementation
- send pull request