forked from rawongithub/minitest-rails-shoulda
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rafal Wrzochol
committed
Oct 22, 2012
1 parent
4ca3133
commit 9957cd5
Showing
1 changed file
with
2 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,3 @@ | ||
= minitest-rails-shoulda | ||
|
||
Make shoulda-matchers available for minitest-rails. | ||
|
||
== Installation | ||
|
||
In Rails 3 and Bundler, add the following to your Gemfile: | ||
|
||
group :test do | ||
gem "minitest-rails-shoulda" | ||
end | ||
|
||
Add the following to your test helper: | ||
|
||
require "minitest/rails/shoulda" | ||
|
||
== Usage | ||
|
||
=== ActiveRecord Matchers | ||
|
||
Matchers to test associations: | ||
|
||
describe Post do | ||
subject { Post.new } | ||
it { must belong_to(:user) } | ||
it { must have_many(:tags).through(:taggings) } | ||
end | ||
|
||
describe User do | ||
subject { User.new } | ||
it { must have_many(:posts) } | ||
end | ||
|
||
=== ActiveModel Matchers | ||
|
||
Matchers to test validations and mass assignments: | ||
|
||
describe Post do | ||
subject { Post.new } | ||
it { must validate_uniqueness_of(:title) } | ||
it { must validate_presence_of(:body).with_message(/wtf/) } | ||
it { must validate_presence_of(:title) } | ||
it { must validate_numericality_of(:user_id) } | ||
end | ||
|
||
describe User do | ||
subject { User.new } | ||
it { wont allow_value("blah").for(:email) } | ||
it { must allow_value("a@b.com").for(:email) } | ||
it { must ensure_inclusion_of(:age).in_range(1..100) } | ||
it { wont 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 { must assign_to(:user) } | ||
it { must respond_with(:success) } | ||
it { must render_template(:show) } | ||
it { wont set_the_flash } | ||
end | ||
end | ||
=== NOTE: | ||
|
||
This repository is no longer maintained. Please use https://github.com/bousquet/minitest-rails-shoulda |