rspec 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +57 -32
- data/EXAMPLES.rd +0 -0
- data/Rakefile +22 -21
- data/bin/spec +9 -11
- data/doc/README +1 -3
- data/doc/plugin/syntax.rb +27 -5
- data/doc/src/core_team.page +22 -0
- data/doc/src/default.css +11 -11
- data/doc/src/default.template +0 -1
- data/doc/src/documentation/index.page +183 -8
- data/doc/src/documentation/meta.info +7 -7
- data/doc/src/documentation/mocks.page +168 -109
- data/doc/src/documentation/underscores.page +20 -0
- data/doc/src/examples.page +2 -1
- data/doc/src/images/David_and_Aslak.jpg +0 -0
- data/doc/src/images/Whats_That_Dude.jpg +0 -0
- data/doc/src/index.page +70 -3
- data/doc/src/meta.info +18 -11
- data/doc/src/tools/index.page +40 -134
- data/doc/src/tools/meta.info +9 -3
- data/doc/src/tools/rails.page +3 -1
- data/doc/src/tools/rake.page +20 -3
- data/doc/src/tools/rcov.page +19 -0
- data/doc/src/tools/spec.page +99 -0
- data/doc/src/tools/test2rspec.page +2 -4
- data/doc/src/tutorials/index.page +52 -0
- data/doc/src/tutorials/meta.info +31 -0
- data/doc/src/tutorials/notes.txt +252 -0
- data/doc/src/tutorials/stack.rb +11 -0
- data/doc/src/tutorials/stack_01.page +224 -0
- data/doc/src/tutorials/stack_02.page +180 -0
- data/doc/src/tutorials/stack_03.page +291 -0
- data/doc/src/tutorials/stack_04.page +203 -0
- data/doc/src/tutorials/stack_04.page.orig +123 -0
- data/doc/src/tutorials/stack_05.page +90 -0
- data/doc/src/tutorials/stack_05.page.orig +124 -0
- data/doc/src/tutorials/stack_06.page +359 -0
- data/doc/src/tutorials/stack_06.page.orig +359 -0
- data/doc/src/tutorials/stack_spec.rb +41 -0
- data/examples/airport_spec.rb +4 -4
- data/examples/{spec_framework_spec.rb → bdd_framework_spec.rb} +6 -7
- data/examples/mocking_spec.rb +0 -5
- data/examples/stack_spec.rb +6 -7
- data/examples/sugar_spec.rb +14 -0
- data/lib/spec/api.rb +5 -2
- data/lib/spec/api/helper/should_base.rb +17 -22
- data/lib/spec/api/helper/should_helper.rb +4 -3
- data/lib/spec/api/helper/should_negator.rb +3 -2
- data/lib/spec/api/mocks/argument_expectation.rb +104 -0
- data/lib/spec/api/{mock.rb → mocks/message_expectation.rb} +47 -96
- data/lib/spec/api/mocks/mock.rb +63 -0
- data/lib/spec/api/mocks/order_group.rb +21 -0
- data/lib/spec/api/sugar.rb +47 -0
- data/lib/spec/rake/rcov_verify.rb +45 -0
- data/lib/spec/rake/spectask.rb +41 -56
- data/lib/spec/runner.rb +4 -1
- data/lib/spec/runner/backtrace_tweaker.rb +24 -3
- data/lib/spec/runner/base_text_formatter.rb +28 -0
- data/lib/spec/runner/context.rb +21 -18
- data/lib/spec/runner/context_runner.rb +20 -31
- data/lib/spec/runner/execution_context.rb +3 -3
- data/lib/spec/runner/kernel_ext.rb +10 -1
- data/lib/spec/runner/option_parser.rb +32 -14
- data/lib/spec/runner/progress_bar_formatter.rb +21 -0
- data/lib/spec/runner/rdoc_formatter.rb +15 -5
- data/lib/spec/runner/reporter.rb +100 -0
- data/lib/spec/runner/specdoc_formatter.rb +20 -0
- data/lib/spec/runner/specification.rb +42 -22
- data/lib/spec/version.rb +1 -1
- data/test/rcov/rcov_testtask.rb +1 -0
- data/test/spec/api/duck_type_test.rb +4 -4
- data/test/spec/api/helper/raising_test.rb +37 -17
- data/test/spec/api/{mock_arg_constraints_test.rb → mocks/mock_arg_constraints_test.rb} +10 -4
- data/test/spec/api/mocks/mock_ordering_test.rb +62 -0
- data/test/spec/api/{mock_test.rb → mocks/mock_test.rb} +30 -7
- data/test/spec/api/mocks/null_object_test.rb +31 -0
- data/test/spec/api/sugar_test.rb +71 -0
- data/test/spec/runner/backtrace_tweaker_test.rb +52 -4
- data/test/spec/runner/context_runner_test.rb +41 -21
- data/test/spec/runner/context_test.rb +60 -32
- data/test/spec/runner/execution_context_test.rb +4 -3
- data/test/spec/runner/failure_dump_test.rb +92 -0
- data/test/spec/runner/kernel_ext_test.rb +1 -2
- data/test/spec/runner/option_parser_test.rb +48 -28
- data/test/spec/runner/progress_bar_formatter_test.rb +48 -0
- data/test/spec/runner/rdoc_formatter_test.rb +31 -4
- data/test/spec/runner/reporter_test.rb +103 -0
- data/test/spec/runner/specdoc_formatter_test.rb +50 -0
- data/test/spec/runner/specification_test.rb +49 -11
- data/test/test_helper.rb +1 -4
- metadata +46 -15
- data/doc/src/community.page +0 -7
- data/doc/src/documentation/api.page +0 -185
- data/doc/src/why_rspec.page +0 -7
- data/examples/empty_stack_spec.rb +0 -22
- data/examples/team_spec.rb +0 -30
- data/lib/spec/api/duck_type.rb +0 -16
- data/lib/spec/runner/simple_text_reporter.rb +0 -88
- data/test/rcov/rcov_verify.rb +0 -28
- data/test/spec/runner/simple_text_reporter_test.rb +0 -123
@@ -1,22 +1,22 @@
|
|
1
1
|
index.page:
|
2
|
-
|
3
|
-
|
4
|
-
api.page:
|
5
|
-
orderInfo: 11
|
2
|
+
inMenu: 11
|
6
3
|
|
4
|
+
underscores.page:
|
5
|
+
orderInfo: 13
|
6
|
+
|
7
7
|
mocks.page:
|
8
|
-
orderInfo:
|
8
|
+
orderInfo: 14
|
9
9
|
|
10
10
|
rdoc.html:
|
11
11
|
title: RDoc
|
12
12
|
dest: ../rdoc/index.html
|
13
13
|
inMenu: true
|
14
|
-
orderInfo:
|
14
|
+
orderInfo: 15
|
15
15
|
|
16
16
|
rcov.html:
|
17
17
|
title: RCov
|
18
18
|
dest: ../coverage/index.html
|
19
19
|
inMenu: true
|
20
|
-
orderInfo:
|
20
|
+
orderInfo: 16
|
21
21
|
|
22
22
|
|
@@ -8,193 +8,252 @@ RSpec contains a full featured Mock Objects framework.
|
|
8
8
|
|
9
9
|
h3. Creating a mock
|
10
10
|
|
11
|
-
<
|
12
|
-
mock(<name>)
|
13
|
-
</
|
11
|
+
<ruby>
|
12
|
+
my_mock = mock(<name>)
|
13
|
+
</ruby>
|
14
14
|
|
15
|
-
This creates a new mock with the given name (a string) and registers it. When the specification finishes, all registered mocks are verified.
|
15
|
+
This creates a new mock with the given <code>name</code> (a string) and registers it. When the specification finishes, all registered mocks are verified.
|
16
16
|
|
17
|
-
<
|
18
|
-
mock(<name>, <options>)
|
19
|
-
</
|
17
|
+
<ruby>
|
18
|
+
my_mock = mock(<name>, <options>)
|
19
|
+
</ruby>
|
20
20
|
|
21
|
-
As above, but allows you to specific options to tweak the mock's behaviour. The <code>options</code> argument is a hash. Currently the only supported option is <code>:null_object</code>. Setting this to true
|
21
|
+
As above, but allows you to specific options to tweak the mock's behaviour. The <code>options</code> argument is a hash. Currently the only supported option is <code>:null_object</code>. Setting this to true instructs the mock to ignore (quietly consume) any messages it hasn't been told to expect. I.e.:
|
22
|
+
|
23
|
+
<ruby>
|
24
|
+
my_mock = mock("blah", :null_object => true)
|
25
|
+
</ruby>
|
22
26
|
|
23
27
|
h3. Expecting Messages
|
24
28
|
|
25
|
-
<
|
26
|
-
|
27
|
-
</
|
29
|
+
<ruby>
|
30
|
+
my_mock.should.receive(<message>)
|
31
|
+
</ruby>
|
28
32
|
|
29
|
-
The <code>message</code> argument is a symbol that is the name of a message that you want
|
30
|
-
the mock to be expecting.
|
33
|
+
The <code>message</code> argument is a symbol that is the name of a message that you want the mock to expect.
|
31
34
|
|
32
|
-
h3. Arbitrary
|
35
|
+
h3. Arbitrary Handling of Received Messages
|
33
36
|
|
34
37
|
You can supply a block to a message expectation. When the message is received
|
35
38
|
by the mock, the block is evaluated, and passed any arguments. The result is
|
36
39
|
the return value of the message. For example:
|
37
40
|
|
38
|
-
<
|
39
|
-
|
40
|
-
</
|
41
|
+
<ruby>
|
42
|
+
my_mock.should.receive(:random_call) {| a | a.should.be true}
|
43
|
+
</ruby>
|
41
44
|
|
42
|
-
This allows arbitrary argument validation and result computation.
|
45
|
+
This allows arbitrary argument validation and result computation. It's handy and kind of cool to be able to do this, but I advise against it. Mocks should not be functional. they should be completely declarative. That said, it's sometimes useful to give them some minimal behaviour.
|
43
46
|
|
44
47
|
h3. Expecting Arguments
|
45
48
|
|
46
|
-
<
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
<ruby>
|
50
|
+
my_mock.should.receive(:msg).with(<args>)
|
51
|
+
</ruby>
|
52
|
+
|
53
|
+
for example:
|
54
|
+
|
55
|
+
<ruby>
|
56
|
+
my_mock.should.receive(:msg).with(1, 2, 3)
|
57
|
+
</ruby>
|
50
58
|
|
51
|
-
The <code>args</code> argument is a series of arguments (e
|
52
|
-
to be passed as arguments to the associated message.
|
59
|
+
The <code>args</code> argument is a series of arguments (e.g. 1, 2, 3) that are expected to be passed as arguments to the associated message.
|
53
60
|
|
54
|
-
<
|
55
|
-
|
56
|
-
</
|
61
|
+
<ruby>
|
62
|
+
my_mock.should.receive(:msg).with(:no_args)
|
63
|
+
</ruby>
|
57
64
|
|
58
|
-
|
65
|
+
The message (<code>msg</code>) is expected to be passed no arguments.
|
59
66
|
|
60
|
-
<
|
61
|
-
|
62
|
-
</
|
67
|
+
<ruby>
|
68
|
+
my_mock.should.receive(:msg).with(:any_args)
|
69
|
+
</ruby>
|
63
70
|
|
64
|
-
Any arguments are to be accepted
|
65
|
-
arguments are provided. *This is the default when no <code>with()</code> clause is
|
66
|
-
specified.* Even so, sometimes you want to be explicit about it.
|
71
|
+
Any arguments (and any number of arguments) are to be accepted. This includes cases where no arguments are provided. *This is the default when no <code>with()</code> clause is specified.* Even so, sometimes you want to be explicit about it.
|
67
72
|
|
68
73
|
h3. Argument Constraints
|
69
74
|
|
70
|
-
Constraints can be placed on individual arguments which are looser than value equivalence.
|
75
|
+
Constraints can be placed on individual arguments which are looser than value equivalence (as above).
|
71
76
|
|
72
77
|
h4. :anything
|
73
78
|
|
74
|
-
accepts any value for this argument
|
79
|
+
accepts any value for this argument, e.g.:
|
75
80
|
|
76
|
-
<
|
77
|
-
|
78
|
-
</
|
81
|
+
<ruby>
|
82
|
+
my_mock.should.receive(:msg).with(1, :anything, "A")
|
83
|
+
</ruby>
|
79
84
|
|
80
85
|
h4. :numeric
|
81
86
|
|
82
|
-
accepts any numeric value for this argument
|
87
|
+
accepts any numeric value for this argument, e.g.:
|
83
88
|
|
84
|
-
<
|
85
|
-
|
86
|
-
</
|
89
|
+
<ruby>
|
90
|
+
my_mock.should.receive(:msg).with(a, :numeric, "b")
|
91
|
+
</ruby>
|
87
92
|
|
88
93
|
h4. :boolean
|
89
94
|
|
90
|
-
accepts a boolean value for this argument
|
95
|
+
accepts a boolean value for this argument, e.g.:
|
91
96
|
|
92
|
-
<
|
93
|
-
|
94
|
-
</
|
97
|
+
<ruby>
|
98
|
+
my_mock.should.receive(:msg).with(a, :boolean, "b")
|
99
|
+
</ruby>
|
95
100
|
|
96
101
|
h4. :string
|
97
102
|
|
98
|
-
accepts any string for this argument
|
103
|
+
accepts any string for this argument, e.g.:
|
99
104
|
|
100
|
-
<
|
101
|
-
|
102
|
-
</
|
105
|
+
<ruby>
|
106
|
+
my_mock.should.receive(:msg).with(a, :string, "b")
|
107
|
+
</ruby>
|
103
108
|
|
104
109
|
h4. duck_type(message(s))
|
105
110
|
|
106
|
-
accepts any object that responds to the prescribed message(s)
|
111
|
+
accepts any object that responds to the prescribed message(s), e.g.:
|
107
112
|
|
108
|
-
<
|
113
|
+
<ruby>
|
109
114
|
#accepts a Fixnum for the second arg
|
110
|
-
|
111
|
-
</
|
115
|
+
my_mock.should.receive(:msg).with(a, duck_type(:abs, :div), "b")
|
116
|
+
</ruby>
|
112
117
|
|
113
118
|
h3. Receive Counts
|
114
119
|
|
115
|
-
<
|
116
|
-
|
117
|
-
</
|
120
|
+
<ruby>
|
121
|
+
my_mock.should.receive(:msg).never
|
122
|
+
</ruby>
|
118
123
|
|
119
|
-
|
124
|
+
An exception is raised if the message is ever received.
|
120
125
|
|
121
|
-
<
|
122
|
-
|
123
|
-
</
|
126
|
+
<ruby>
|
127
|
+
my_mock.should.receive(:msg).any.number.of.times
|
128
|
+
</ruby>
|
124
129
|
|
125
130
|
The message can be received 0 or more times.
|
126
131
|
|
127
|
-
<
|
128
|
-
|
129
|
-
</
|
132
|
+
<ruby>
|
133
|
+
my_mock.should.receive(:msg).once
|
134
|
+
</ruby>
|
130
135
|
|
131
|
-
|
132
|
-
than once.
|
136
|
+
An exception is raised if the message is never received, or it is received more than once.
|
133
137
|
|
134
|
-
<
|
135
|
-
|
136
|
-
</
|
138
|
+
<ruby>
|
139
|
+
my_mock.should.receive(:msg).twice
|
140
|
+
</ruby>
|
137
141
|
|
138
|
-
|
142
|
+
An exception is raised if the message is received anything but two times.
|
139
143
|
|
140
|
-
<
|
141
|
-
|
142
|
-
</
|
144
|
+
<ruby>
|
145
|
+
my_mock.should.receive(:msg).exactly(n).times
|
146
|
+
</ruby>
|
143
147
|
|
144
|
-
|
148
|
+
An exception is raised if the message is received anything but <code>n</code> times.
|
145
149
|
|
146
|
-
<
|
147
|
-
|
148
|
-
</
|
150
|
+
<ruby>
|
151
|
+
my_mock.should.receive(:msg).at.least(:once)
|
152
|
+
</ruby>
|
149
153
|
|
150
|
-
|
154
|
+
An exception is raised if the message is never received.
|
151
155
|
|
152
|
-
<
|
153
|
-
|
154
|
-
</
|
156
|
+
<ruby>
|
157
|
+
my_mock.should.receive(:msg).at.least(:twice)
|
158
|
+
</ruby>
|
155
159
|
|
156
|
-
|
160
|
+
An exception is raised if the message is never received or is received only once.
|
157
161
|
|
158
|
-
<
|
159
|
-
|
160
|
-
</
|
162
|
+
<ruby>
|
163
|
+
my_mock.should.receive(:msg).at.least(n).times
|
164
|
+
</ruby>
|
161
165
|
|
162
|
-
|
166
|
+
An exception is raised if the message is received fewer than <code>n</code> times.
|
163
167
|
|
164
168
|
h3. Return Values
|
165
169
|
|
166
|
-
|
167
|
-
mock.should.receive(:msg).once.and.return(<value>)
|
168
|
-
</pre>
|
170
|
+
h4. Single return value
|
169
171
|
|
170
|
-
|
172
|
+
<ruby>
|
173
|
+
my_mock.should.receive(:msg).once.and.return(<value>)
|
174
|
+
</ruby>
|
171
175
|
|
172
|
-
<
|
176
|
+
Each time the expected message is received, <code>value</code> will be returned as the result.
|
177
|
+
|
178
|
+
h4. Consequtive return values
|
179
|
+
|
180
|
+
<ruby>
|
173
181
|
and.return([<value-1>, <value-2>, ..., <value-n>])
|
174
|
-
</
|
182
|
+
</ruby>
|
183
|
+
|
184
|
+
When the expected message is received, <code>value-i</code> will be returned as the result for the ith reception of the message. After the message has been received <code>i</code> times, <code>value-n</code> is returned for all
|
185
|
+
subsequent receives.
|
175
186
|
|
176
|
-
|
177
|
-
for the ith reception of the message. Once <code>i > n</code>, <code>value-n</code> is returned for all
|
178
|
-
subsequent receives of the message.
|
187
|
+
*Note:* if you wish to have a single return value that is an array, you must use this form, with one item that is the array to return. Otherwise your array will be interpreted as a series of return values. For example:
|
179
188
|
|
180
|
-
<
|
181
|
-
|
182
|
-
</
|
189
|
+
<ruby>
|
190
|
+
and.return([[1, 2, 3]])
|
191
|
+
</ruby>
|
192
|
+
|
193
|
+
h4. Computed return value
|
194
|
+
|
195
|
+
<ruby>
|
196
|
+
my_mock.should.receive(:msg).once.and.return {...}
|
197
|
+
</ruby>
|
183
198
|
|
184
199
|
When the expected message is received, the result of evaluating the supplied
|
185
200
|
block will be returned as the result. The block is passed any arguments passed
|
186
|
-
as
|
187
|
-
based on the arguments. For example:
|
201
|
+
as arguments of the message. This capability can be used to compute return values based on the arguments. For example:
|
188
202
|
|
189
|
-
<
|
190
|
-
|
191
|
-
</
|
203
|
+
<ruby>
|
204
|
+
my_mock.should.receive(:msg).with(:numeric, :numeric) once.and.return {|a, b| a + b}
|
205
|
+
</ruby>
|
192
206
|
|
193
207
|
h3. Raising and Throwing
|
194
208
|
|
195
|
-
<
|
196
|
-
|
197
|
-
|
198
|
-
</
|
209
|
+
<ruby>
|
210
|
+
my_mock.should.receive(:msg).once.and.raise(<exception>)
|
211
|
+
my_mock.should.receive(:msg).once.and.throw(<symbol>)
|
212
|
+
</ruby>
|
213
|
+
|
214
|
+
These instruct the mock to raise an exception or throw a symbol, respectively, instead of returning a value.
|
215
|
+
|
216
|
+
h3. Yielding
|
217
|
+
|
218
|
+
<ruby>
|
219
|
+
my_mock.should.receive(:msg).once.and.yield([<value-1>, <value-2>, ..., <value-n>])
|
220
|
+
</ruby>
|
221
|
+
|
222
|
+
When the expected message is received, the mock will yield the values to the passed block.
|
223
|
+
|
224
|
+
h3. Ordering
|
225
|
+
|
226
|
+
There are times when you want to specify the order of messages sent to a mock.
|
227
|
+
It shouldn't be the case very often, but it can be handy at times.
|
228
|
+
|
229
|
+
Labeling expectations as being ordered is done by the <code>ordered</code> call:
|
230
|
+
|
231
|
+
<ruby>
|
232
|
+
my_mock.should.receive(:flip).once.ordered
|
233
|
+
my_mock.should.receive(:flop).once.ordered
|
234
|
+
</ruby>
|
235
|
+
|
236
|
+
If the send of <code>flop</code> is seen before <code>flip</code> the specification will fail.
|
237
|
+
|
238
|
+
Of course, chains of ordered expectations can be set up:
|
239
|
+
|
240
|
+
<ruby>
|
241
|
+
my_mock.should.receive(:one).ordered
|
242
|
+
my_mock.should.receive(:two).ordered
|
243
|
+
my_mock.should.receive(:three).ordered
|
244
|
+
</ruby>
|
245
|
+
|
246
|
+
The expected order is the order in which the expectations are declared.
|
247
|
+
|
248
|
+
Order-independant expectations can be set anywhere in the expectation sequence, in any order. Only the order of expectations tagged with the <code>ordered</code> call is significant. Likewise, calls to order-independant methods can be made in any order, even interspersed with calls to order-dependant methods. For example:
|
199
249
|
|
200
|
-
|
250
|
+
<ruby>
|
251
|
+
my_mock.should.receive(:zero)
|
252
|
+
my_mock.should.receive(:one).ordered
|
253
|
+
my_mock.should.receive(:two).ordered
|
254
|
+
my_mock.should.receive(:one_and_a_half)
|
255
|
+
my_mock.one
|
256
|
+
my_mock.one_and_a_half
|
257
|
+
my_mock.zero
|
258
|
+
my_mock.two
|
259
|
+
</ruby>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
title: Underscore sugar
|
3
|
+
inMenu: true
|
4
|
+
---
|
5
|
+
h2. Underscore sugar
|
6
|
+
|
7
|
+
If you feel that the various dots hurt your eyes and is not very 'rubyish',
|
8
|
+
you can replace your dots with underscores, so that instead of saying
|
9
|
+
|
10
|
+
<ruby>
|
11
|
+
lambda { 1.should.not.equal 1 }.should.raise
|
12
|
+
</ruby>
|
13
|
+
|
14
|
+
you can say
|
15
|
+
|
16
|
+
<ruby>
|
17
|
+
lambda { 1.should_not_equal 1 }.should_raise
|
18
|
+
</ruby>
|
19
|
+
|
20
|
+
This applies to regular Ruby objects as well as mocks.
|
data/doc/src/examples.page
CHANGED
Binary file
|
Binary file
|
data/doc/src/index.page
CHANGED
@@ -1,7 +1,74 @@
|
|
1
1
|
---
|
2
|
-
title: Overview
|
2
|
+
title: Overview
|
3
3
|
inMenu: true
|
4
|
-
---
|
4
|
+
---
|
5
|
+
|
6
|
+
h2. Behaviour Driven Development
|
7
|
+
|
8
|
+
Test Driven Development (TDD) has you define the behaviour of your system by
|
9
|
+
writing small tests that precisely define some small piece of your system's
|
10
|
+
behaviour. Then you implement that behaviour. Then you clean up & improve your
|
11
|
+
design.
|
12
|
+
|
13
|
+
At least that's how you're supposed to do it.
|
14
|
+
|
15
|
+
This focus on behaviour is the real value in TDD, and marks the genuinely
|
16
|
+
experienced TDD practitioner.
|
17
|
+
|
18
|
+
However, with the ubiquity of testing related terminology in TDD and it's
|
19
|
+
supporting frameworks, it is no surprise that it takes beginners some time to
|
20
|
+
get to the understanding that TDD isn't about testing at all... if they ever
|
21
|
+
do.
|
22
|
+
|
23
|
+
The aim of BDD is to address this shortcoming and, by using terminology
|
24
|
+
focused on the behavioural aspects of the system rather than testing, attempt
|
25
|
+
to help direct developers towards a focus on the real value to be found in TDD
|
26
|
+
at its most successful, or BDD as we call it.
|
27
|
+
|
28
|
+
(paraphrased from "behaviour-driven.org":http://behaviour-driven.org)
|
29
|
+
|
30
|
+
Dan North, who was the first to coin the term BDD, and who has been actively
|
31
|
+
refining it since, started promoting BDD in 2003. "JBehave":http://jbehave.codehaus.org/
|
32
|
+
was the first BDD framework to support this new thinking.
|
33
|
+
|
5
34
|
h2. RSpec
|
6
35
|
|
7
|
-
|
36
|
+
RSpec is a framework for practicing __Behaviour Driven Development__ (BDD) in Ruby.
|
37
|
+
|
38
|
+
It all started with a blogpost
|
39
|
+
("A New Look at Test Driven Development":http://blog.daveastels.com/articles/2005/07/05/a-new-look-at-test-driven-development)
|
40
|
+
of Dave's where he talked about his ideas for BDD and a BDD framework. One thing he mentioned was that his ideas
|
41
|
+
would be easily implemented in Smalltalk, and probably Ruby.
|
42
|
+
|
43
|
+
Steven Baker wrote the first version of the rspec core. Dave added mock support (initially inspired from Schmock by
|
44
|
+
Ben Griffiths). Dave and David had met & talked about BDD at Agile'05 just after Dave's blog
|
45
|
+
post (above). David started thinking about a BDD framework in C#. As fate, or
|
46
|
+
the gods, would have it Dave & David ended up working at the same client in
|
47
|
+
the greater Chicago area, allowing them to explore some ideas resulting in the totally rewriting of the expectation mechanism.
|
48
|
+
Aslak joined in and the three rewrote the higher level syntax and the core, reworking RSpec into what you see now:
|
49
|
+
|
50
|
+
<ruby>
|
51
|
+
context "BDD framework" do
|
52
|
+
|
53
|
+
setup do
|
54
|
+
@bdd_framework = BddFramework.new
|
55
|
+
end
|
56
|
+
|
57
|
+
specify "should be adopted quickly" do
|
58
|
+
@bdd_framework.should.be.adopted_quickly
|
59
|
+
end
|
60
|
+
|
61
|
+
specify "should be intuitive" do
|
62
|
+
@bdd_framework.should.be.intuitive
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
</ruby>
|
67
|
+
|
68
|
+
RSpec provides a framework for writing what we call __executable
|
69
|
+
specifications of program behaviour__. Since that's rather wordy, we usually
|
70
|
+
just call them __specs__.
|
71
|
+
"Some other people":http://www.testing.com/cgi-bin/blog/2006/04/12#spec-vs-example call these things __examples__.
|
72
|
+
|
73
|
+
On this site you will find examples, documentation, and tutorials as well as
|
74
|
+
links to download and community resources.
|