/usr/share/doc/ruby-shoulda-matchers/README.rdoc is in ruby-shoulda-matchers 1.0.0~beta2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | = shoulda-matchers
{Official Documentation}[http://rubydoc.info/github/thoughtbot/shoulda-matchers/master/frames]
Test::Unit- and RSpec-compatible one-liners that test common Rails functionality.
These tests would otherwise be much longer, more complex, and error-prone.
Refer to the {shoulda}[https://github.com/thoughtbot/shoulda] gem if you want to know more
about using shoulda with Test::Unit.
=== ActiveRecord Matchers
Matchers to test associations and validations:
describe Post do
it { should belong_to(:user) }
it { should have_many(:tags).through(:taggings) }
it { should validate_uniqueness_of(:title) }
it { should validate_presence_of(:body).with_message(/wtf/) }
it { should validate_presence_of(:title) }
it { should validate_numericality_of(:user_id) }
end
describe User do
it { should have_many(:posts) }
it { should_not allow_value("blah").for(:email) }
it { should allow_value("a@b.com").for(:email) }
it { should ensure_inclusion_of(:age).in_range(1..100) }
it { should_not allow_mass_assignment_of(:password) }
end
=== ActionController Matchers
Matchers to test common patterns:
describe PostsController, "#show" do
context "for a fictional user" do
before do
get :show, :id => 1
end
it { should assign_to(:user) }
it { should respond_with(:success) }
it { should render_template(:show) }
it { should_not set_the_flash }
end
end
= Installation
In Rails 3 and Bundler, add the following to your Gemfile:
group :test do
gem "shoulda-matchers"
gem "rspec-rails"
end
Shoulda will automatically include matchers into the appropriate example groups.
= Credits
Shoulda is maintained and funded by {thoughtbot}[http://thoughtbot.com/community].
Thank you to all the {contributors}[https://github.com/thoughtbot/shoulda-matchers/contributors].
= License
Shoulda is Copyright © 2006-2010 thoughtbot, inc.
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|