Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 107 lines (70 sloc) 3.132 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
851d199 @dchelimsky add travis build status
dchelimsky authored
3 RSpec Core provides the structure for writing executable examples of how your
4 code should behave.
5
6 [![build status](http://travis-ci.org/rspec/rspec-core.png)](http://travis-ci.org/rspec/rspec-core)
5c8d5ec @dchelimsky update readme
dchelimsky authored
7
4c5e75d @dchelimsky links to docs
dchelimsky authored
8 ## Documentation
c75fe9c @dchelimsky note to see Upgrade.markdown
dchelimsky authored
9
d0d9e89 @dchelimsky prep for 2.3.0 release
dchelimsky authored
10 The [Cucumber features](http://relishapp.com/rspec/rspec-core) are the
3d0ac2b @dchelimsky explain README links to documentation
dchelimsky authored
11 most comprehensive and up-to-date docs for end-users.
12
d0d9e89 @dchelimsky prep for 2.3.0 release
dchelimsky authored
13 The [RDoc](http://rubydoc.info/gems/rspec-core/2.3.0/frames) provides
3d0ac2b @dchelimsky explain README links to documentation
dchelimsky authored
14 additional information for contributors and/or extenders.
15
16 All of the documentation is open source and a work in progress. If you find it
17 lacking or confusing, you can help improve it by submitting requests and
18 patches to the [rspec-core issue
19 tracker](https://github.com/rspec/rspec-core/issues).
c75fe9c @dchelimsky note to see Upgrade.markdown
dchelimsky authored
20
fada219 @dchelimsky words
dchelimsky authored
21 ## Install
22
4c5e75d @dchelimsky links to docs
dchelimsky authored
23 gem install rspec # for rspec-core, rspec-expectations, rspec-mocks
24 gem install rspec-core # for rspec-core only
25
26 ## Upgrading from rspec-1.x
27
f1a43fd @dchelimsky update upgrade link
dchelimsky authored
28 See [features/Upgrade.md](http://github.com/rspec/rspec-core/blob/master/features/Upgrade.md)
4c5e75d @dchelimsky links to docs
dchelimsky authored
29
fada219 @dchelimsky words
dchelimsky authored
30
d81c090 @dchelimsky words
dchelimsky authored
31 This will install the rspec, rspec-core, rspec-expectations and rspec-mocks
32 gems.
71d3926 @dchelimsky words
dchelimsky authored
33
f1a8e72 @dchelimsky update README
dchelimsky authored
34 ## Get Started
71d3926 @dchelimsky words
dchelimsky authored
35
f1a8e72 @dchelimsky update README
dchelimsky authored
36 Start with a simple example of behavior you expect from your system. Do
ab44fca @dchelimsky words
dchelimsky authored
37 this before you write any implementation code:
71d3926 @dchelimsky words
dchelimsky authored
38
f1a8e72 @dchelimsky update README
dchelimsky authored
39 # in spec/calculator_spec.rb
40 describe Calculator, "add" do
41 it "returns the sum of its arguments" do
42 Calculator.new.add(1, 2).should eq(3)
71d3926 @dchelimsky words
dchelimsky authored
43 end
44 end
45
f1a8e72 @dchelimsky update README
dchelimsky authored
46 Run this with the rspec command, and watch it fail:
71d3926 @dchelimsky words
dchelimsky authored
47
f1a8e72 @dchelimsky update README
dchelimsky authored
48 $ rspec spec/calculator_spec.rb
49 ./spec/calculator_spec.rb:1: uninitialized constant Calculator
71d3926 @dchelimsky words
dchelimsky authored
50
f1a8e72 @dchelimsky update README
dchelimsky authored
51 Implement the simplest solution:
71d3926 @dchelimsky words
dchelimsky authored
52
f1a8e72 @dchelimsky update README
dchelimsky authored
53 # in lib/calculator.rb
54 class Calculator
55 def add(a,b)
56 a + b
71d3926 @dchelimsky words
dchelimsky authored
57 end
58 end
fada219 @dchelimsky words
dchelimsky authored
59
f1a8e72 @dchelimsky update README
dchelimsky authored
60 Be sure to require the implementation file in the spec:
61
62 # in spec/calculator_spec.rb
bcb1dfa @dchelimsky change top-level module from Rspec to RSpec
dchelimsky authored
63 # - RSpec adds ./lib to the $LOAD_PATH, so you can
f1a8e72 @dchelimsky update README
dchelimsky authored
64 # just require "calculator" directly
65 require "calculator"
66
67 Now run the spec again, and watch it pass:
3d0ac2b @dchelimsky explain README links to documentation
dchelimsky authored
68
f1a8e72 @dchelimsky update README
dchelimsky authored
69 $ rspec spec/calculator_spec.rb
70 .
71
72 Finished in 0.000315 seconds
73 1 example, 0 failures
74
75 Use the documentation formatter to see the resulting spec:
76
77 $ rspec spec/calculator_spec.rb --format doc
78 Calculator add
79 returns the sum of its arguments
80
81 Finished in 0.000379 seconds
82 1 example, 0 failures
83
bb091f7 @dchelimsky add link to github issues to README
dchelimsky authored
84 ## Known issues
85
7e0ffd0 @dchelimsky see?
dchelimsky authored
86 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
87
cb0aa59 @dchelimsky add info about cukes to README
dchelimsky authored
88 ## Learn more
89
90 While not comprehensive yet, you can learn quite a lot from the Cucumber
91 features in the [features
92 directory](http://github.com/rspec/rspec-core/tree/master/features/). If there
93 is a feature that is not documented there, or you find them insufficient to
94 understand how to use a feature, please submit issues to
95 [http://github.com/rspec/rspec-core/issues](http://github.com/rspec/rspec-core/issues).
96
4e796d6 @dchelimsky words
dchelimsky authored
97 ## Contribute
98
99 See [http://github.com/rspec/rspec-dev](http://github.com/rspec/rspec-dev)
100
101 ## Also see
fada219 @dchelimsky words
dchelimsky authored
102
103 * [http://github.com/rspec/rspec](http://github.com/rspec/rspec)
104 * [http://github.com/rspec/rspec-expectations](http://github.com/rspec/rspec-expectations)
105 * [http://github.com/rspec/rspec-mocks](http://github.com/rspec/rspec-mocks)
106
Something went wrong with that request. Please try again.