Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 55 lines (37 sloc) 1.823 kb
fbd3c78 @gabebw Convert README to Markdown.
gabebw authored
1 # shoulda-context
2
3 [Official Documentation](http://rubydoc.info/github/thoughtbot/shoulda-context/master/frames)
4
5 Shoulda's contexts make it easy to write understandable and maintainable tests for Test::Unit.
6 It's fully compatible with your existing tests in Test::Unit, and requires no retooling to use.
7
8 Refer to the [shoulda](https://github.com/thoughtbot/shoulda) gem if you want to know more
9 about using shoulda with Rails or RSpec.
10
11 ## Contexts
12
13 Instead of writing Ruby methods with `lots_of_underscores`, shoulda-context adds
14 context, setup, and should blocks...
15
16 class CalculatorTest < Test::Unit::TestCase
17 context "a calculator" do
18 setup do
19 @calculator = Calculator.new
20 end
21
22 should "add two numbers for the sum" do
23 assert_equal 4, @calculator.sum(2, 2)
24 end
25
26 should "multiply two numbers for the product" do
27 assert_equal 10, @calculator.product(2, 5)
28 end
29 end
30 end
31
32 ... which combine to produce the following test methods:
33
34 "test: a calculator should add two numbers for the sum."
35 "test: a calculator should multiply two numbers for the product."
36
37 ## Assertions
38
39 It also has two additional Test::Unit assertions for working with Ruby's Array:
40
41 assert_same_elements([:a, :b, :c], [:c, :a, :b])
42 assert_contains(['a', '1'], /\d/)
43 assert_contains(['a', '1'], 'a')
44
45 ## Credits
46
47 Shoulda is maintained and funded by [thoughtbot](http://thoughtbot.com/community).
48 shoulda-context is maintained by [Travis Jeffery](https://github.com/travisjeffery).
49 Thank you to all the [contributors](https://github.com/thoughtbot/shoulda-context/contributors).
50
51 ## License
52
53 Shoulda is Copyright © 2006-2012 thoughtbot, inc.
54 It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
Something went wrong with that request. Please try again.