Repository is archived
No commit activity in last 3 years
No release in over 3 years
A collection of RSpec matchers that understand Rails conventions, allowing for more concise specs.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

rspec-tag_matchers¶ ↑

rspec-tag_matchers is a collection of RSpec matchers for testing Rails views. The matchers can match against any string containing HTML or any object whose to_s method returns a string containing HTML (this includes Nokogiri classes). They assume Rails conventions. For example, the has_form matcher looks for a hidden input named _method when testing a form’s method.

Example¶ ↑

describe "users/new.html.haml" do
  before(:each) do
    assign(:user, User.new)
    render
  end

  it { should have_form.with_verb(:post).with_action(user_path) }
  it { should have_checkbox.for(:user => :terms_of_service) }
end

Getting Started¶ ↑

  • Add rspec-tag_matchers to your Gemfile:

    group :test do
      gem "rspec-tag_matchers"
    end
    
  • Add the tag matchers to the RSpec context. In spec_helper:

    RSpec.configure do |config|
      config.include RSpec::TagMatchers
    end
    
  • Now you can use the tag matchers in your RSpec tests. The included matchers are documented here: rdoc.info/github/dcuddeback/rspec-tag_matchers/master/RSpec/TagMatchers.

Status¶ ↑

rspec-tag_matchers is tested against Ruby 1.8.7, 1.9.2, 1.9.3, REE, Rubinius (1.8 and 1.9 modes) and JRuby.

<img src=“https://secure.travis-ci.org/dcuddeback/rspec-tag_matchers.png?branch=master” />

The library is well tested, but the collection of matchers is incomplete. I’m adding more on an as-needed basis. Please feel free to fork this repository to add your own then send me a pull request.

Contributing to rspec-tag_matchers¶ ↑

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it

  • Fork the project

  • Start a feature/bugfix branch

  • Commit and push until you are happy with your contribution

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2011 David Cuddeback. See LICENSE.txt for further details.