Browse files

brand new documentation

  • Loading branch information...
1 parent d1c6ba6 commit 891c94c7ce7c0e5b6fc4310ab547aac4e270b1f4 @croaky croaky committed Dec 15, 2010
Showing with 19 additions and 18 deletions.
  1. +19 −18 README.rdoc
@@ -1,52 +1,53 @@
= shoulda-context
+{Official Documentation}[]
Shoulda's contexts make it easy to write understandable and maintainable tests for Test::Unit.
It's fully compatible with your existing tests in Test::Unit, and requires no retooling to use.
+Refer to the {shoulda}[] gem if you want to know more
+about using shoulda with Rails or RSpec.
== Contexts
-Stop killing your fingers with all of those underscores... Name your tests with plain sentences!
+Instead of writing Ruby methods with lots_of_underscores, shoulda-context adds
+context, setup, and should blocks...
- class UserTest < Test::Unit::TestCase
- context "A User instance" do
+ class CalculatorTest < Test::Unit::TestCase
+ context "a calculator" do
setup do
- @user = User.find(:first)
+ @calculator =
- should "return its full name" do
- assert_equal "John Doe", @user.full_name
+ should "add two numbers for the sum" do
+ assert_equal 4, @calculator.sum(2, 2)
- context "with a profile" do
- setup do
- @user.profile = Profile.find(:first)
- end
- should "return true when sent #has_profile?" do
- assert @user.has_profile?
- end
+ should "multiply two numbers for the product" do
+ assert_equal 10, @calculator.product(2, 5)
-Produces the following test methods:
+... which combine to produce the following test methods:
"test: A User instance should return its full name."
"test: A User instance with a profile should return true when sent #has_profile?."
-So readable!
== Assertions
+It also has two additional Test::Unit assertions for working with Ruby's Array:
assert_same_elements([:a, :b, :c], [:c, :a, :b])
assert_contains(['a', '1'], /\d/)
assert_contains(['a', '1'], 'a')
= Credits
Shoulda is maintained and funded by {thoughtbot}[].
+Thank you to all the {contributors}[].
= License
-Shoulda is Copyright © 2010 thoughtbot, inc.
+Shoulda is Copyright © 2006-2010 thoughtbot, inc.
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.

0 comments on commit 891c94c

Please sign in to comment.