Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 89 lines (58 sloc) 2.364 kB
bcb1dfa @dchelimsky change top-level module from Rspec to RSpec
dchelimsky authored
1 # RSpec Core
7b8b714 @spicycode Version bump to 0.0.0
spicycode authored
2
ab44fca @dchelimsky words
dchelimsky authored
3 Behaviour Driven Development for Ruby
5c8d5ec @dchelimsky update readme
dchelimsky authored
4
c75fe9c @dchelimsky note to see Upgrade.markdown
dchelimsky authored
5 ## Upgrading from rspec-1.x
6
60bfe75 @dchelimsky add link to Upgrade.markdown on github to README
dchelimsky authored
7 See [Upgrade.markdown](http://github.com/rspec/rspec-core/blob/master/Upgrade.markdown)
c75fe9c @dchelimsky note to see Upgrade.markdown
dchelimsky authored
8
fada219 @dchelimsky words
dchelimsky authored
9 ## Install
10
ab44fca @dchelimsky words
dchelimsky authored
11 gem install rspec --prerelease
fada219 @dchelimsky words
dchelimsky authored
12
d81c090 @dchelimsky words
dchelimsky authored
13 This will install the rspec, rspec-core, rspec-expectations and rspec-mocks
14 gems.
71d3926 @dchelimsky words
dchelimsky authored
15
f1a8e72 @dchelimsky update README
dchelimsky authored
16 ## Get Started
71d3926 @dchelimsky words
dchelimsky authored
17
f1a8e72 @dchelimsky update README
dchelimsky authored
18 Start with a simple example of behavior you expect from your system. Do
ab44fca @dchelimsky words
dchelimsky authored
19 this before you write any implementation code:
71d3926 @dchelimsky words
dchelimsky authored
20
f1a8e72 @dchelimsky update README
dchelimsky authored
21 # in spec/calculator_spec.rb
22 describe Calculator, "add" do
23 it "returns the sum of its arguments" do
24 Calculator.new.add(1, 2).should eq(3)
71d3926 @dchelimsky words
dchelimsky authored
25 end
26 end
27
f1a8e72 @dchelimsky update README
dchelimsky authored
28 Run this with the rspec command, and watch it fail:
71d3926 @dchelimsky words
dchelimsky authored
29
f1a8e72 @dchelimsky update README
dchelimsky authored
30 $ rspec spec/calculator_spec.rb
31 ./spec/calculator_spec.rb:1: uninitialized constant Calculator
71d3926 @dchelimsky words
dchelimsky authored
32
f1a8e72 @dchelimsky update README
dchelimsky authored
33 Implement the simplest solution:
71d3926 @dchelimsky words
dchelimsky authored
34
f1a8e72 @dchelimsky update README
dchelimsky authored
35 # in lib/calculator.rb
36 class Calculator
37 def add(a,b)
38 a + b
71d3926 @dchelimsky words
dchelimsky authored
39 end
40 end
fada219 @dchelimsky words
dchelimsky authored
41
f1a8e72 @dchelimsky update README
dchelimsky authored
42 Be sure to require the implementation file in the spec:
43
44 # in spec/calculator_spec.rb
bcb1dfa @dchelimsky change top-level module from Rspec to RSpec
dchelimsky authored
45 # - RSpec adds ./lib to the $LOAD_PATH, so you can
f1a8e72 @dchelimsky update README
dchelimsky authored
46 # just require "calculator" directly
47 require "calculator"
48
49 Now run the spec again, and watch it pass:
50
51 $ rspec spec/calculator_spec.rb
52 .
53
54 Finished in 0.000315 seconds
55 1 example, 0 failures
56
57 Use the documentation formatter to see the resulting spec:
58
59 $ rspec spec/calculator_spec.rb --format doc
60 Calculator add
61 returns the sum of its arguments
62
63 Finished in 0.000379 seconds
64 1 example, 0 failures
65
bb091f7 @dchelimsky add link to github issues to README
dchelimsky authored
66 ## Known issues
67
7e0ffd0 @dchelimsky see?
dchelimsky authored
68 See [http://github.com/rspec/rspec-core/issues](http://github.com/rspec/rspec-core/issues)
bb091f7 @dchelimsky add link to github issues to README
dchelimsky authored
69
cb0aa59 @dchelimsky add info about cukes to README
dchelimsky authored
70 ## Learn more
71
72 While not comprehensive yet, you can learn quite a lot from the Cucumber
73 features in the [features
74 directory](http://github.com/rspec/rspec-core/tree/master/features/). If there
75 is a feature that is not documented there, or you find them insufficient to
76 understand how to use a feature, please submit issues to
77 [http://github.com/rspec/rspec-core/issues](http://github.com/rspec/rspec-core/issues).
78
4e796d6 @dchelimsky words
dchelimsky authored
79 ## Contribute
80
81 See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
82
83 ## Also see
fada219 @dchelimsky words
dchelimsky authored
84
85 * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
86 * [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
87 * [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks)
88
Something went wrong with that request. Please try again.