A pack of shoulda macros for testing Rails apps.
script/plugin install git://github.com/maxim/shmacros.git
should_accept_nested_attributes_for :foo, :bar
accepts_nested_attribtes_foris declared for given attributes.
acts_as_taggable_onis declared for optionally given category.
Verifies that tested model
should_callback :method_name, :after_save
Verifies that given callback (
:method_name) is declared for given event (
should_delegate :foo, :bar, :to => :elsewhere, :allow_nil => true
delegatesis declared for given method to given destination. Also tests
:allow_nilfunctionality introduced in Rails 2.3.3.
should_validate_associated :foo, :bar
validates_associatedis declared for given attributes.
should_deny_values :country => %w(Africa Europe), :zipcode => "fake_code"
Verifies that tested model is invalid when given attributes are assigned corresponding values. As opposed to shoulda's similar method, this implementation doesn't compare error messages, just checks for error presence on attribute.
should_allow_values :country => %w(England Russia), :zipcode => "55555"
Verifies that tested model is valid when given attributes are assigned corresponding values. As opposed to shoulda's similar method, this implementation doesn't compare error messages, just checks for error presence on attribute.
should_allow_mass_assignment_of :foo, :bar, :strict => true
should_allow_mass_assignment_ofto add the convenience option
:strict => true. When
trueevery non-listed attribute is explicitly tested for mass assignment protection.
should_rest_route :show, :new, :create
Provides shortcut to declaring multiple
should_routetests if routes are supposed to be REST-style. If action names are omitted defaults to testing all 7 RESTful actions. Accepts option
:singular => truefor singular routes such as profile or account controller.
Copyright (c) 2009 Maxim Chernyak
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.