public
Description: A collection of RSpec matchers to be used with the Ruby on Rails project
Clone URL: git://github.com/joshknowles/rspec-on-rails-matchers.git
mattAimonetti (author)
Wed Jan 02 23:54:54 -0800 2008
commit  fa1900e0e4b66705c47deae9a39a44f134f7c1aa
tree    090e9c34d5d8e4365676b2602bf834384af3cfff
parent  b10cbef46989b932566eb4404f76c76dcd8cf56f
name age message
file CHANGELOG Wed Jan 02 22:50:07 -0800 2008 Updated Readme to reflect contributions from Br... [joshknowles]
file MIT-LICENSE Wed Jan 02 22:50:07 -0800 2008 Updated Readme to reflect contributions from Br... [joshknowles]
file README Wed Jan 02 23:54:54 -0800 2008 added text_area matchers. updated the readme file. [mattAimonetti]
file TODO Wed Jan 02 22:50:07 -0800 2008 Updated Readme to reflect contributions from Br... [joshknowles]
file init.rb Wed Jan 02 22:50:07 -0800 2008 Updated Readme to reflect contributions from Br... [joshknowles]
directory lib/ Wed Jan 02 23:54:54 -0800 2008 added text_area matchers. updated the readme file. [mattAimonetti]
README
rspec-on-rails-matchers
=======================

Setup
------

    script/plugin install http://rspec-on-rails-matchers.googlecode.com/svn/trunk/
or
    svn checkout http://rspec-on-rails-matchers.googlecode.com/svn/trunk/ vendor/plugins/rspec_on_rails_matchers
    
Textmate bundle:
http://rspec-on-rails-matchers.googlecode.com/files/RSpecOnRailsMatchers.tmbundle.zip


Dependencies:
-------------

RSpec, RSpec_on_rails: http://rspec.info/documentation/rails/install.html


Overview
--------

Adds the following RSpec matchers:

  * Associations:
    Verify that the association has been defined. (doesn't verify that the association works!)

    object.should have_many(:association)
    example: @post.should have_many(:comments)
    TM snippet: [mshm + tab] (Model Should Have Many)

    object.should belong_to(:association)
    example: @comment.should belong_to(:post)
    TM snippet: [msbt + tab]

    object.should have_one(:association)
    user.should have_one(:social_security_number)
    TM snippet: [msho + tab]

    object.should have_and_belong_to_many(:association)
    project.should have_and_belong_to_many(:categories)
    TM snippet: [mshabtm + tab]


  * Validations:
    Verify that a validation has been defined. (doesn't test the validation itself)

    object.should validate_presence_of(:attribute)
    TM snippet: [msvp + tab]

    object.should validate_confirmation_of(:attribute)
    TM snippet: [msvc + tab]

    object.should validate_uniqueness_of(:attribute)
    TM snippet: [msvu + tab]

    object.should validate_length_of(:attribute, :between => 5..10)
    TM snippet: [msvl + tab]


  * Views:
    Verifies that the views contains some tags.

    response.should have_form_posting_to(url_or_path)
    TM snippet: [hfpt + tab]

    response.should have_text_field_for(:attribute)
    TM snippet: [htff + tab]

    response.should have_label_for(:attribute)
    TM snippet: [hlf + tab]

    response.should have_password_field_for(:attribute)
    TM snippet: [hpff + tab]

    response.should have_checkbox_for(:attribute)
    TM snippet: [hcf + tab]

    response.should have_submit_button
    TM snippet: [hsb + tab]

    response.should have_link_to(url_or_path, "optional_text")
    TM snippet: [hlt + tab]

    * nested view tests:
      for instance:

      response.should have_form_posting_to(url_or_path) do
        with_text_field_for(:attribute)
      end

      with_text_field_for(:attribute)
      TM snippet: [wtff + tab]

      with_label_for(:attribute)
      TM snippet: [wlf + tab]

      with_password_field_for(:attribute)
      TM snippet: [wpff + tab]

      with_checkbox_for(:attribute)
      TM snippet: [wcf + tab]

      with_submit_button
      TM snippet: [wsb + tab]

      with_link_to(url_or_path, "optional_text")
      TM snippet: [wlt + tab]


Usage:
------

In your view:

    it "should render new form" do
        render "/users/new.html.erb"

        response.should have_form_posting_to(users_path) do
          with_text_field_for(:user_name)
          with_text_area_for(:user_address)
          with_text_field_for(:user_login)
          with_text_field_for(:user_email)
          with_submit_button
        end
    end
    
Bugs, feature requests?
-----------------------

Bug tracker: http://code.google.com/p/rspec-on-rails-matchers/issues/list

More info: http://code.google.com/p/rspec-on-rails-matchers


Core Contributors
-----------------

  * Josh Knowles <joshknowles@gmail.com>
  * Bryan Helmkamp <bryan@brynary.com>
  * Matt Aimonetti <mattaimonetti@gmail.com>

Copyright (c) 2008 The Plugin Development Team, released under the MIT license