rr 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,810 +1,820 @@
1
1
  require "spec/spec_helper"
2
2
 
3
3
  module RR
4
- describe DoubleDefinition, :shared => true do
5
- before do
6
- @space = Space.new
7
- @object = Object.new
8
- add_original_method
9
- @double_injection = @space.double_injection(@object, :foobar)
10
- @double = @space.double(@double_injection)
11
- @definition = @double.definition
12
- end
4
+ describe DoubleDefinition, :shared => true do
5
+ before do
6
+ @space = Space.new
7
+ @object = Object.new
8
+ add_original_method
9
+ @double_injection = @space.double_injection(@object, :foobar)
10
+ @double = @space.double(@double_injection)
11
+ @definition = @double.definition
12
+ end
13
13
 
14
- def add_original_method
15
- def @object.foobar(a, b)
16
- :original_return_value
14
+ def add_original_method
15
+ def @object.foobar(a, b)
16
+ :original_return_value
17
+ end
17
18
  end
18
19
  end
19
- end
20
20
 
21
- describe DoubleDefinition, " with returns block_callback_strategy", :shared => true do
22
- before do
23
- @definition.returns_block_callback_strategy!
24
- create_definition
21
+ describe DoubleDefinition, " with returns block_callback_strategy", :shared => true do
22
+ before do
23
+ @definition.returns_block_callback_strategy!
24
+ create_definition
25
+ end
25
26
  end
26
- end
27
27
 
28
- describe DoubleDefinition, " with after_call block_callback_strategy", :shared => true do
29
- before do
30
- @definition.implemented_by_original_method
31
- @definition.after_call_block_callback_strategy!
32
- create_definition
28
+ describe DoubleDefinition, " with after_call block_callback_strategy", :shared => true do
29
+ before do
30
+ @definition.implemented_by_original_method
31
+ @definition.after_call_block_callback_strategy!
32
+ create_definition
33
+ end
33
34
  end
34
- end
35
35
 
36
- describe DoubleDefinition, "#with", :shared => true do
37
- it_should_behave_like "RR::DoubleDefinition"
36
+ describe DoubleDefinition, "#with", :shared => true do
37
+ it_should_behave_like "RR::DoubleDefinition"
38
38
 
39
- it "returns DoubleDefinition" do
40
- @definition.with(1).should === @definition
41
- end
39
+ it "returns DoubleDefinition" do
40
+ @definition.with(1).should === @definition
41
+ end
42
42
 
43
- it "sets an ArgumentEqualityExpectation" do
44
- @definition.should be_exact_match(1, 2)
45
- @definition.should_not be_exact_match(2)
46
- end
43
+ it "sets an ArgumentEqualityExpectation" do
44
+ @definition.should be_exact_match(1, 2)
45
+ @definition.should_not be_exact_match(2)
46
+ end
47
47
 
48
- def create_definition
49
- actual_args = nil
50
- @definition.with(1, 2) do |*args|
51
- actual_args = args
52
- :new_return_value
48
+ def create_definition
49
+ actual_args = nil
50
+ @definition.with(1, 2) do |*args|
51
+ actual_args = args
52
+ :new_return_value
53
+ end
54
+ @object.foobar(1, 2)
55
+ @return_value = @object.foobar(1, 2)
56
+ @args = actual_args
53
57
  end
54
- @object.foobar(1, 2)
55
- @return_value = @object.foobar(1, 2)
56
- @args = actual_args
57
58
  end
58
- end
59
59
 
60
- describe DoubleDefinition, "#with with returns block_callback_strategy" do
61
- it_should_behave_like "RR::DoubleDefinition#with"
62
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
60
+ describe DoubleDefinition, "#with with returns block_callback_strategy" do
61
+ it_should_behave_like "RR::DoubleDefinition#with"
62
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
63
63
 
64
- it "sets return value when block passed in" do
65
- @return_value.should == :new_return_value
66
- @args.should == [1, 2]
64
+ it "sets return value when block passed in" do
65
+ @return_value.should == :new_return_value
66
+ @args.should == [1, 2]
67
+ end
67
68
  end
68
- end
69
69
 
70
- describe DoubleDefinition, "#with with after_call block_callback_strategy" do
71
- it_should_behave_like "RR::DoubleDefinition#with"
72
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
70
+ describe DoubleDefinition, "#with with after_call block_callback_strategy" do
71
+ it_should_behave_like "RR::DoubleDefinition#with"
72
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
73
73
 
74
- it "sets return value when block passed in" do
75
- @return_value.should == :new_return_value
76
- @args.should == [:original_return_value]
74
+ it "sets return value when block passed in" do
75
+ @return_value.should == :new_return_value
76
+ @args.should == [:original_return_value]
77
+ end
77
78
  end
78
- end
79
79
 
80
- describe DoubleDefinition, "#with_any_args", :shared => true do
81
- it_should_behave_like "RR::DoubleDefinition"
80
+ describe DoubleDefinition, "#with_any_args", :shared => true do
81
+ it_should_behave_like "RR::DoubleDefinition"
82
82
 
83
- it "returns DoubleDefinition" do
84
- @definition.with_no_args.should === @definition
85
- end
83
+ it "returns DoubleDefinition" do
84
+ @definition.with_no_args.should === @definition
85
+ end
86
86
 
87
- it "sets an AnyArgumentExpectation" do
88
- @definition.should_not be_exact_match(1)
89
- @definition.should be_wildcard_match(1)
90
- end
87
+ it "sets an AnyArgumentExpectation" do
88
+ @definition.should_not be_exact_match(1)
89
+ @definition.should be_wildcard_match(1)
90
+ end
91
91
 
92
- def create_definition
93
- actual_args = nil
94
- @definition.with_any_args do |*args|
95
- actual_args = args
96
- :new_return_value
92
+ def create_definition
93
+ actual_args = nil
94
+ @definition.with_any_args do |*args|
95
+ actual_args = args
96
+ :new_return_value
97
+ end
98
+ @return_value = @object.foobar(1, 2)
99
+ @args = actual_args
97
100
  end
98
- @return_value = @object.foobar(1, 2)
99
- @args = actual_args
100
101
  end
101
- end
102
102
 
103
- describe DoubleDefinition, "#with_any_args with returns block_callback_strategy" do
104
- it_should_behave_like "RR::DoubleDefinition#with_any_args"
105
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
103
+ describe DoubleDefinition, "#with_any_args with returns block_callback_strategy" do
104
+ it_should_behave_like "RR::DoubleDefinition#with_any_args"
105
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
106
106
 
107
- it "sets return value when block passed in" do
108
- @return_value.should == :new_return_value
109
- @args.should == [1, 2]
107
+ it "sets return value when block passed in" do
108
+ @return_value.should == :new_return_value
109
+ @args.should == [1, 2]
110
+ end
110
111
  end
111
- end
112
112
 
113
- describe DoubleDefinition, "#with_any_args with after_call block_callback_strategy" do
114
- it_should_behave_like "RR::DoubleDefinition#with_any_args"
115
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
113
+ describe DoubleDefinition, "#with_any_args with after_call block_callback_strategy" do
114
+ it_should_behave_like "RR::DoubleDefinition#with_any_args"
115
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
116
116
 
117
- it "sets return value when block passed in" do
118
- @return_value.should == :new_return_value
119
- @args.should == [:original_return_value]
117
+ it "sets return value when block passed in" do
118
+ @return_value.should == :new_return_value
119
+ @args.should == [:original_return_value]
120
+ end
120
121
  end
121
- end
122
122
 
123
- describe DoubleDefinition, "#with_no_args", :shared => true do
124
- it_should_behave_like "RR::DoubleDefinition"
123
+ describe DoubleDefinition, "#with_no_args", :shared => true do
124
+ it_should_behave_like "RR::DoubleDefinition"
125
125
 
126
- it "returns DoubleDefinition" do
127
- @definition.with_no_args.should === @definition
128
- end
126
+ it "returns DoubleDefinition" do
127
+ @definition.with_no_args.should === @definition
128
+ end
129
129
 
130
- it "sets an ArgumentEqualityExpectation with no arguments" do
131
- @definition.argument_expectation.should == Expectations::ArgumentEqualityExpectation.new()
132
- end
130
+ it "sets an ArgumentEqualityExpectation with no arguments" do
131
+ @definition.argument_expectation.should == Expectations::ArgumentEqualityExpectation.new()
132
+ end
133
133
 
134
- def add_original_method
135
- def @object.foobar()
136
- :original_return_value
134
+ def add_original_method
135
+ def @object.foobar()
136
+ :original_return_value
137
+ end
137
138
  end
138
- end
139
139
 
140
- def create_definition
141
- actual_args = nil
142
- @definition.with_no_args do |*args|
143
- actual_args = args
144
- :new_return_value
140
+ def create_definition
141
+ actual_args = nil
142
+ @definition.with_no_args do |*args|
143
+ actual_args = args
144
+ :new_return_value
145
+ end
146
+ @return_value = @object.foobar
147
+ @args = actual_args
145
148
  end
146
- @return_value = @object.foobar
147
- @args = actual_args
148
149
  end
149
- end
150
150
 
151
- describe DoubleDefinition, "#with_no_args with returns block_callback_strategy" do
152
- it_should_behave_like "RR::DoubleDefinition#with_no_args"
153
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
151
+ describe DoubleDefinition, "#with_no_args with returns block_callback_strategy" do
152
+ it_should_behave_like "RR::DoubleDefinition#with_no_args"
153
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
154
154
 
155
- it "sets return value when block passed in" do
156
- @return_value.should == :new_return_value
157
- @args.should == []
155
+ it "sets return value when block passed in" do
156
+ @return_value.should == :new_return_value
157
+ @args.should == []
158
+ end
158
159
  end
159
- end
160
160
 
161
- describe DoubleDefinition, "#with_no_args with after_call block_callback_strategy" do
162
- it_should_behave_like "RR::DoubleDefinition#with_no_args"
163
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
161
+ describe DoubleDefinition, "#with_no_args with after_call block_callback_strategy" do
162
+ it_should_behave_like "RR::DoubleDefinition#with_no_args"
163
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
164
164
 
165
- it "sets return value when block passed in" do
166
- @return_value.should == :new_return_value
167
- @args.should == [:original_return_value]
165
+ it "sets return value when block passed in" do
166
+ @return_value.should == :new_return_value
167
+ @args.should == [:original_return_value]
168
+ end
168
169
  end
169
- end
170
170
 
171
- describe DoubleDefinition, "#never" do
172
- it_should_behave_like "RR::DoubleDefinition"
171
+ describe DoubleDefinition, "#never" do
172
+ it_should_behave_like "RR::DoubleDefinition"
173
173
 
174
- it "returns DoubleDefinition" do
175
- @definition.never.should === @definition
176
- end
174
+ it "returns DoubleDefinition" do
175
+ @definition.never.should === @definition
176
+ end
177
177
 
178
- it "sets up a Times Called Expectation with 0" do
179
- @definition.with_any_args
180
- @definition.never
181
- proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
182
- end
178
+ it "sets up a Times Called Expectation with 0" do
179
+ @definition.with_any_args
180
+ @definition.never
181
+ proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
182
+ end
183
183
 
184
- it "sets return value when block passed in" do
185
- @definition.with_any_args.never
186
- proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
184
+ it "sets return value when block passed in" do
185
+ @definition.with_any_args.never
186
+ proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
187
+ end
187
188
  end
188
- end
189
189
 
190
- describe DoubleDefinition, "#once", :shared => true do
191
- it_should_behave_like "RR::DoubleDefinition"
190
+ describe DoubleDefinition, "#once", :shared => true do
191
+ it_should_behave_like "RR::DoubleDefinition"
192
192
 
193
- it "returns DoubleDefinition" do
194
- @definition.once.should === @definition
195
- end
193
+ it "returns DoubleDefinition" do
194
+ @definition.once.should === @definition
195
+ end
196
196
 
197
- it "sets up a Times Called Expectation with 1" do
198
- proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
199
- end
197
+ it "sets up a Times Called Expectation with 1" do
198
+ proc {@object.foobar}.should raise_error(Errors::TimesCalledError)
199
+ end
200
200
 
201
- def create_definition
202
- actual_args = nil
203
- @definition.with_any_args.once do |*args|
204
- actual_args = args
205
- :new_return_value
201
+ def create_definition
202
+ actual_args = nil
203
+ @definition.with_any_args.once do |*args|
204
+ actual_args = args
205
+ :new_return_value
206
+ end
207
+ @return_value = @object.foobar(1, 2)
208
+ @args = actual_args
206
209
  end
207
- @return_value = @object.foobar(1, 2)
208
- @args = actual_args
209
210
  end
210
- end
211
211
 
212
- describe DoubleDefinition, "#once with returns block_callback_strategy" do
213
- it_should_behave_like "RR::DoubleDefinition#once"
214
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
212
+ describe DoubleDefinition, "#once with returns block_callback_strategy" do
213
+ it_should_behave_like "RR::DoubleDefinition#once"
214
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
215
215
 
216
- it "sets return value when block passed in" do
217
- @return_value.should == :new_return_value
218
- @args.should == [1, 2]
216
+ it "sets return value when block passed in" do
217
+ @return_value.should == :new_return_value
218
+ @args.should == [1, 2]
219
+ end
219
220
  end
220
- end
221
221
 
222
- describe DoubleDefinition, "#once with after_call block_callback_strategy" do
223
- it_should_behave_like "RR::DoubleDefinition#once"
224
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
222
+ describe DoubleDefinition, "#once with after_call block_callback_strategy" do
223
+ it_should_behave_like "RR::DoubleDefinition#once"
224
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
225
225
 
226
- it "sets return value when block passed in" do
227
- @return_value.should == :new_return_value
228
- @args.should == [:original_return_value]
226
+ it "sets return value when block passed in" do
227
+ @return_value.should == :new_return_value
228
+ @args.should == [:original_return_value]
229
+ end
229
230
  end
230
- end
231
231
 
232
- describe DoubleDefinition, "#twice", :shared => true do
233
- it_should_behave_like "RR::DoubleDefinition"
232
+ describe DoubleDefinition, "#twice", :shared => true do
233
+ it_should_behave_like "RR::DoubleDefinition"
234
234
 
235
- it "returns DoubleDefinition" do
236
- @definition.twice.should === @definition
237
- end
235
+ it "returns DoubleDefinition" do
236
+ @definition.twice.should === @definition
237
+ end
238
238
 
239
- it "sets up a Times Called Expectation with 2" do
240
- @definition.twice.with_any_args
241
- proc {@object.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
242
- end
239
+ it "sets up a Times Called Expectation with 2" do
240
+ @definition.twice.with_any_args
241
+ proc {@object.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
242
+ end
243
243
 
244
- def create_definition
245
- actual_args = nil
246
- @definition.with_any_args.twice do |*args|
247
- actual_args = args
248
- :new_return_value
244
+ def create_definition
245
+ actual_args = nil
246
+ @definition.with_any_args.twice do |*args|
247
+ actual_args = args
248
+ :new_return_value
249
+ end
250
+ @object.foobar(1, 2)
251
+ @return_value = @object.foobar(1, 2)
252
+ @args = actual_args
249
253
  end
250
- @object.foobar(1, 2)
251
- @return_value = @object.foobar(1, 2)
252
- @args = actual_args
253
254
  end
254
- end
255
255
 
256
- describe DoubleDefinition, "#twice with returns block_callback_strategy" do
257
- it_should_behave_like "RR::DoubleDefinition#twice"
258
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
256
+ describe DoubleDefinition, "#twice with returns block_callback_strategy" do
257
+ it_should_behave_like "RR::DoubleDefinition#twice"
258
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
259
259
 
260
- it "sets return value when block passed in" do
261
- @return_value.should == :new_return_value
262
- @args.should == [1, 2]
260
+ it "sets return value when block passed in" do
261
+ @return_value.should == :new_return_value
262
+ @args.should == [1, 2]
263
+ end
263
264
  end
264
- end
265
265
 
266
- describe DoubleDefinition, "#twice with after_call block_callback_strategy" do
267
- it_should_behave_like "RR::DoubleDefinition#twice"
268
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
266
+ describe DoubleDefinition, "#twice with after_call block_callback_strategy" do
267
+ it_should_behave_like "RR::DoubleDefinition#twice"
268
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
269
269
 
270
- it "sets return value when block passed in" do
271
- @return_value.should == :new_return_value
272
- @args.should == [:original_return_value]
270
+ it "sets return value when block passed in" do
271
+ @return_value.should == :new_return_value
272
+ @args.should == [:original_return_value]
273
+ end
273
274
  end
274
- end
275
275
 
276
- describe DoubleDefinition, "#at_least", :shared => true do
277
- it_should_behave_like "RR::DoubleDefinition"
276
+ describe DoubleDefinition, "#at_least", :shared => true do
277
+ it_should_behave_like "RR::DoubleDefinition"
278
278
 
279
- it "returns DoubleDefinition" do
280
- @definition.with_any_args.at_least(2).should === @definition
281
- end
279
+ it "returns DoubleDefinition" do
280
+ @definition.with_any_args.at_least(2).should === @definition
281
+ end
282
282
 
283
- it "sets up a Times Called Expectation with 1" do
284
- @definition.times_matcher.should == TimesCalledMatchers::AtLeastMatcher.new(2)
285
- end
283
+ it "sets up a Times Called Expectation with 1" do
284
+ @definition.times_matcher.should == TimesCalledMatchers::AtLeastMatcher.new(2)
285
+ end
286
286
 
287
- def create_definition
288
- actual_args = nil
289
- @definition.with_any_args.at_least(2) do |*args|
290
- actual_args = args
291
- :new_return_value
287
+ def create_definition
288
+ actual_args = nil
289
+ @definition.with_any_args.at_least(2) do |*args|
290
+ actual_args = args
291
+ :new_return_value
292
+ end
293
+ @object.foobar(1, 2)
294
+ @return_value = @object.foobar(1, 2)
295
+ @args = actual_args
292
296
  end
293
- @object.foobar(1, 2)
294
- @return_value = @object.foobar(1, 2)
295
- @args = actual_args
296
297
  end
297
- end
298
298
 
299
- describe DoubleDefinition, "#at_least with returns block_callback_strategy" do
300
- it_should_behave_like "RR::DoubleDefinition#at_least"
301
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
299
+ describe DoubleDefinition, "#at_least with returns block_callback_strategy" do
300
+ it_should_behave_like "RR::DoubleDefinition#at_least"
301
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
302
302
 
303
- it "sets return value when block passed in" do
304
- @return_value.should == :new_return_value
305
- @args.should == [1, 2]
303
+ it "sets return value when block passed in" do
304
+ @return_value.should == :new_return_value
305
+ @args.should == [1, 2]
306
+ end
306
307
  end
307
- end
308
308
 
309
- describe DoubleDefinition, "#at_least with after_call block_callback_strategy" do
310
- it_should_behave_like "RR::DoubleDefinition#at_least"
311
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
309
+ describe DoubleDefinition, "#at_least with after_call block_callback_strategy" do
310
+ it_should_behave_like "RR::DoubleDefinition#at_least"
311
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
312
312
 
313
- it "sets return value when block passed in" do
314
- @return_value.should == :new_return_value
315
- @args.should == [:original_return_value]
313
+ it "sets return value when block passed in" do
314
+ @return_value.should == :new_return_value
315
+ @args.should == [:original_return_value]
316
+ end
316
317
  end
317
- end
318
318
 
319
- describe DoubleDefinition, "#at_most", :shared => true do
320
- it_should_behave_like "RR::DoubleDefinition"
319
+ describe DoubleDefinition, "#at_most", :shared => true do
320
+ it_should_behave_like "RR::DoubleDefinition"
321
321
 
322
- it "returns DoubleDefinition" do
323
- @definition.with_any_args.at_most(2).should === @definition
324
- end
322
+ it "returns DoubleDefinition" do
323
+ @definition.with_any_args.at_most(2).should === @definition
324
+ end
325
325
 
326
- it "sets up a Times Called Expectation with 1" do
327
- proc do
328
- @object.foobar
329
- end.should raise_error(
326
+ it "sets up a Times Called Expectation with 1" do
327
+ proc do
328
+ @object.foobar
329
+ end.should raise_error(
330
330
  Errors::TimesCalledError,
331
331
  "foobar()\nCalled 3 times.\nExpected at most 2 times."
332
- )
333
- end
332
+ )
333
+ end
334
334
 
335
- def create_definition
336
- actual_args = nil
337
- @definition.with_any_args.at_most(2) do |*args|
338
- actual_args = args
339
- :new_return_value
335
+ def create_definition
336
+ actual_args = nil
337
+ @definition.with_any_args.at_most(2) do |*args|
338
+ actual_args = args
339
+ :new_return_value
340
+ end
341
+ @object.foobar(1, 2)
342
+ @return_value = @object.foobar(1, 2)
343
+ @args = actual_args
340
344
  end
341
- @object.foobar(1, 2)
342
- @return_value = @object.foobar(1, 2)
343
- @args = actual_args
344
345
  end
345
- end
346
346
 
347
- describe DoubleDefinition, "#at_most with returns block_callback_strategy" do
348
- it_should_behave_like "RR::DoubleDefinition#at_most"
349
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
347
+ describe DoubleDefinition, "#at_most with returns block_callback_strategy" do
348
+ it_should_behave_like "RR::DoubleDefinition#at_most"
349
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
350
350
 
351
- it "sets return value when block passed in" do
352
- @return_value.should == :new_return_value
353
- @args.should == [1, 2]
351
+ it "sets return value when block passed in" do
352
+ @return_value.should == :new_return_value
353
+ @args.should == [1, 2]
354
+ end
354
355
  end
355
- end
356
356
 
357
- describe DoubleDefinition, "#at_most with after_call block_callback_strategy" do
358
- it_should_behave_like "RR::DoubleDefinition#at_most"
359
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
357
+ describe DoubleDefinition, "#at_most with after_call block_callback_strategy" do
358
+ it_should_behave_like "RR::DoubleDefinition#at_most"
359
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
360
360
 
361
- it "sets return value when block passed in" do
362
- @return_value.should == :new_return_value
363
- @args.should == [:original_return_value]
361
+ it "sets return value when block passed in" do
362
+ @return_value.should == :new_return_value
363
+ @args.should == [:original_return_value]
364
+ end
364
365
  end
365
- end
366
366
 
367
- describe DoubleDefinition, "#times", :shared => true do
368
- it_should_behave_like "RR::DoubleDefinition"
367
+ describe DoubleDefinition, "#times", :shared => true do
368
+ it_should_behave_like "RR::DoubleDefinition"
369
369
 
370
- it "returns DoubleDefinition" do
371
- @definition.times(3).should === @definition
372
- end
370
+ it "returns DoubleDefinition" do
371
+ @definition.times(3).should === @definition
372
+ end
373
373
 
374
- it "sets up a Times Called Expectation with passed in times" do
375
- proc {@object.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
376
- end
374
+ it "sets up a Times Called Expectation with passed in times" do
375
+ proc {@object.foobar(1, 2)}.should raise_error(Errors::TimesCalledError)
376
+ end
377
377
 
378
- def create_definition
379
- actual_args = nil
380
- @definition.with(1, 2).times(3) do |*args|
381
- actual_args = args
382
- :new_return_value
378
+ def create_definition
379
+ actual_args = nil
380
+ @definition.with(1, 2).times(3) do |*args|
381
+ actual_args = args
382
+ :new_return_value
383
+ end
384
+ @object.foobar(1, 2)
385
+ @object.foobar(1, 2)
386
+ @return_value = @object.foobar(1, 2)
387
+ @args = actual_args
383
388
  end
384
- @object.foobar(1, 2)
385
- @object.foobar(1, 2)
386
- @return_value = @object.foobar(1, 2)
387
- @args = actual_args
388
389
  end
389
- end
390
390
 
391
- describe DoubleDefinition, "#times with returns block_callback_strategy" do
392
- it_should_behave_like "RR::DoubleDefinition#times"
393
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
391
+ describe DoubleDefinition, "#times with returns block_callback_strategy" do
392
+ it_should_behave_like "RR::DoubleDefinition#times"
393
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
394
394
 
395
- it "sets return value when block passed in" do
396
- @return_value.should == :new_return_value
397
- @args.should == [1, 2]
395
+ it "sets return value when block passed in" do
396
+ @return_value.should == :new_return_value
397
+ @args.should == [1, 2]
398
+ end
398
399
  end
399
- end
400
400
 
401
- describe DoubleDefinition, "#times with after_call block_callback_strategy" do
402
- it_should_behave_like "RR::DoubleDefinition#times"
403
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
401
+ describe DoubleDefinition, "#times with after_call block_callback_strategy" do
402
+ it_should_behave_like "RR::DoubleDefinition#times"
403
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
404
404
 
405
- it "sets return value when block passed in" do
406
- @return_value.should == :new_return_value
407
- @args.should == [:original_return_value]
405
+ it "sets return value when block passed in" do
406
+ @return_value.should == :new_return_value
407
+ @args.should == [:original_return_value]
408
+ end
408
409
  end
409
- end
410
410
 
411
- describe DoubleDefinition, "#any_number_of_times", :shared => true do
412
- it_should_behave_like "RR::DoubleDefinition"
411
+ describe DoubleDefinition, "#any_number_of_times", :shared => true do
412
+ it_should_behave_like "RR::DoubleDefinition"
413
413
 
414
- it "returns DoubleDefinition" do
415
- @definition.any_number_of_times.should === @definition
416
- end
414
+ it "returns DoubleDefinition" do
415
+ @definition.any_number_of_times.should === @definition
416
+ end
417
417
 
418
- it "sets up a Times Called Expectation with AnyTimes matcher" do
419
- @definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
420
- end
418
+ it "sets up a Times Called Expectation with AnyTimes matcher" do
419
+ @definition.times_matcher.should == TimesCalledMatchers::AnyTimesMatcher.new
420
+ end
421
421
 
422
- def create_definition
423
- actual_args = nil
424
- @definition.with(1, 2).any_number_of_times do |*args|
425
- actual_args = args
426
- :new_return_value
422
+ def create_definition
423
+ actual_args = nil
424
+ @definition.with(1, 2).any_number_of_times do |*args|
425
+ actual_args = args
426
+ :new_return_value
427
+ end
428
+ @object.foobar(1, 2)
429
+ @return_value = @object.foobar(1, 2)
430
+ @args = actual_args
427
431
  end
428
- @object.foobar(1, 2)
429
- @return_value = @object.foobar(1, 2)
430
- @args = actual_args
431
432
  end
432
- end
433
433
 
434
- describe DoubleDefinition, "#any_number_of_times with returns block_callback_strategy" do
435
- it_should_behave_like "RR::DoubleDefinition#any_number_of_times"
436
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
434
+ describe DoubleDefinition, "#any_number_of_times with returns block_callback_strategy" do
435
+ it_should_behave_like "RR::DoubleDefinition#any_number_of_times"
436
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
437
437
 
438
- it "sets return value when block passed in" do
439
- @return_value.should == :new_return_value
440
- @args.should == [1, 2]
438
+ it "sets return value when block passed in" do
439
+ @return_value.should == :new_return_value
440
+ @args.should == [1, 2]
441
+ end
441
442
  end
442
- end
443
443
 
444
- describe DoubleDefinition, "#any_number_of_times with after_call block_callback_strategy" do
445
- it_should_behave_like "RR::DoubleDefinition#any_number_of_times"
446
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
444
+ describe DoubleDefinition, "#any_number_of_times with after_call block_callback_strategy" do
445
+ it_should_behave_like "RR::DoubleDefinition#any_number_of_times"
446
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
447
447
 
448
- it "sets return value when block passed in" do
449
- @return_value.should == :new_return_value
450
- @args.should == [:original_return_value]
448
+ it "sets return value when block passed in" do
449
+ @return_value.should == :new_return_value
450
+ @args.should == [:original_return_value]
451
+ end
451
452
  end
452
- end
453
453
 
454
- describe DoubleDefinition, "#ordered", :shared => true do
455
- it_should_behave_like "RR::DoubleDefinition"
454
+ describe DoubleDefinition, "#ordered", :shared => true do
455
+ it_should_behave_like "RR::DoubleDefinition"
456
456
 
457
- it "adds itself to the ordered doubles list" do
458
- @definition.ordered
459
- @space.ordered_doubles.should include(@double)
460
- end
457
+ it "adds itself to the ordered doubles list" do
458
+ @definition.ordered
459
+ @space.ordered_doubles.should include(@double)
460
+ end
461
461
 
462
- it "does not double_injection add itself" do
463
- @definition.ordered
464
- @space.ordered_doubles.should == [@double]
465
- end
462
+ it "does not double_injection add itself" do
463
+ @definition.ordered
464
+ @space.ordered_doubles.should == [@double]
465
+ end
466
466
 
467
- it "sets ordered? to true" do
468
- @definition.should be_ordered
469
- end
467
+ it "sets ordered? to true" do
468
+ @definition.should be_ordered
469
+ end
470
470
 
471
- it "raises error when there is no Double" do
472
- @definition.double = nil
473
- proc do
474
- @definition.ordered
475
- end.should raise_error(
471
+ it "raises error when there is no Double" do
472
+ @definition.double = nil
473
+ proc do
474
+ @definition.ordered
475
+ end.should raise_error(
476
476
  Errors::DoubleDefinitionError,
477
477
  "Double Definitions must have a dedicated Double to be ordered. " <<
478
478
  "For example, using instance_of does not allow ordered to be used. " <<
479
479
  "proxy the class's #new method instead."
480
- )
481
- end
482
-
483
- def create_definition
484
- actual_args = nil
485
- @definition.with(1, 2).once.ordered do |*args|
486
- actual_args = args
487
- :new_return_value
480
+ )
488
481
  end
489
- @return_value = @object.foobar(1, 2)
490
- @args = actual_args
491
- end
492
- end
493
482
 
494
- describe DoubleDefinition, "#ordered with returns block_callback_strategy" do
495
- it_should_behave_like "RR::DoubleDefinition#ordered"
496
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
497
-
498
- it "sets return value when block passed in" do
499
- @return_value.should == :new_return_value
500
- @args.should == [1, 2]
483
+ def create_definition
484
+ actual_args = nil
485
+ @definition.with(1, 2).once.ordered do |*args|
486
+ actual_args = args
487
+ :new_return_value
488
+ end
489
+ @return_value = @object.foobar(1, 2)
490
+ @args = actual_args
491
+ end
501
492
  end
502
- end
503
493
 
504
- describe DoubleDefinition, "#ordered with after_call block_callback_strategy" do
505
- it_should_behave_like "RR::DoubleDefinition#ordered"
506
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
494
+ describe DoubleDefinition, "#ordered with returns block_callback_strategy" do
495
+ it_should_behave_like "RR::DoubleDefinition#ordered"
496
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
507
497
 
508
- it "sets return value when block passed in" do
509
- @return_value.should == :new_return_value
510
- @args.should == [:original_return_value]
498
+ it "sets return value when block passed in" do
499
+ @return_value.should == :new_return_value
500
+ @args.should == [1, 2]
501
+ end
511
502
  end
512
- end
513
503
 
514
- describe DoubleDefinition, "#ordered?" do
515
- it_should_behave_like "RR::DoubleDefinition"
504
+ describe DoubleDefinition, "#ordered with after_call block_callback_strategy" do
505
+ it_should_behave_like "RR::DoubleDefinition#ordered"
506
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
516
507
 
517
- it "defaults to false" do
518
- @definition.should_not be_ordered
508
+ it "sets return value when block passed in" do
509
+ @return_value.should == :new_return_value
510
+ @args.should == [:original_return_value]
511
+ end
519
512
  end
520
- end
521
513
 
522
- describe DoubleDefinition, "#yields", :shared => true do
523
- it_should_behave_like "RR::DoubleDefinition"
514
+ describe DoubleDefinition, "#ordered?" do
515
+ it_should_behave_like "RR::DoubleDefinition"
524
516
 
525
- it "returns DoubleDefinition" do
526
- @definition.yields(:baz).should === @definition
517
+ it "defaults to false" do
518
+ @definition.should_not be_ordered
519
+ end
527
520
  end
528
521
 
529
- it "yields the passed in argument to the call block when there is a no returns value set" do
530
- @passed_in_block_arg.should == :baz
531
- end
522
+ describe DoubleDefinition, "#yields", :shared => true do
523
+ it_should_behave_like "RR::DoubleDefinition"
532
524
 
533
- def create_definition
534
- actual_args = nil
535
- @definition.with(1, 2).once.yields(:baz) do |*args|
536
- actual_args = args
537
- :new_return_value
525
+ it "returns DoubleDefinition" do
526
+ @definition.yields(:baz).should === @definition
538
527
  end
539
- passed_in_block_arg = nil
540
- @return_value = @object.foobar(1, 2) do |arg|
541
- passed_in_block_arg = arg
528
+
529
+ it "yields the passed in argument to the call block when there is a no returns value set" do
530
+ @passed_in_block_arg.should == :baz
542
531
  end
543
- @passed_in_block_arg = passed_in_block_arg
544
-
545
- @args = actual_args
546
- end
547
- end
548
532
 
549
- describe DoubleDefinition, "#yields with returns block_callback_strategy" do
550
- it_should_behave_like "RR::DoubleDefinition#yields"
551
- it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
533
+ def create_definition
534
+ actual_args = nil
535
+ @definition.with(1, 2).once.yields(:baz) do |*args|
536
+ actual_args = args
537
+ :new_return_value
538
+ end
539
+ passed_in_block_arg = nil
540
+ @return_value = @object.foobar(1, 2) do |arg|
541
+ passed_in_block_arg = arg
542
+ end
543
+ @passed_in_block_arg = passed_in_block_arg
552
544
 
553
- it "sets return value when block passed in" do
554
- @return_value.should == :new_return_value
555
- @args.length.should == 3
556
- @args[0..1].should == [1, 2]
557
- @args[2].should be_instance_of(Proc)
545
+ @args = actual_args
546
+ end
558
547
  end
559
- end
560
548
 
561
- describe DoubleDefinition, "#yields with after_call block_callback_strategy" do
562
- it_should_behave_like "RR::DoubleDefinition#yields"
563
- it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
549
+ describe DoubleDefinition, "#yields with returns block_callback_strategy" do
550
+ it_should_behave_like "RR::DoubleDefinition#yields"
551
+ it_should_behave_like "RR::DoubleDefinition with returns block_callback_strategy"
564
552
 
565
- it "sets return value when block passed in" do
566
- @return_value.should == :new_return_value
567
- @args.should == [:original_return_value]
553
+ it "sets return value when block passed in" do
554
+ @return_value.should == :new_return_value
555
+ @args.length.should == 3
556
+ @args[0..1].should == [1, 2]
557
+ @args[2].should be_instance_of(Proc)
558
+ end
568
559
  end
569
- end
570
560
 
571
- describe DoubleDefinition, "#after_call" do
572
- it_should_behave_like "RR::DoubleDefinition"
561
+ describe DoubleDefinition, "#yields with after_call block_callback_strategy" do
562
+ it_should_behave_like "RR::DoubleDefinition#yields"
563
+ it_should_behave_like "RR::DoubleDefinition with after_call block_callback_strategy"
573
564
 
574
- it "returns DoubleDefinition" do
575
- @definition.after_call {}.should === @definition
565
+ it "sets return value when block passed in" do
566
+ @return_value.should == :new_return_value
567
+ @args.should == [:original_return_value]
568
+ end
576
569
  end
577
570
 
578
- it "sends return value of Double implementation to after_call" do
579
- return_value = {}
580
- @definition.with_any_args.returns(return_value).after_call do |value|
581
- value[:foo] = :bar
582
- value
571
+ describe DoubleDefinition, "#after_call" do
572
+ it_should_behave_like "RR::DoubleDefinition"
573
+
574
+ it "returns DoubleDefinition" do
575
+ @definition.after_call {}.should === @definition
583
576
  end
584
577
 
585
- actual_value = @object.foobar
586
- actual_value.should === return_value
587
- actual_value.should == {:foo => :bar}
588
- end
578
+ it "sends return value of Double implementation to after_call" do
579
+ return_value = {}
580
+ @definition.with_any_args.returns(return_value).after_call do |value|
581
+ value[:foo] = :bar
582
+ value
583
+ end
589
584
 
590
- it "receives the return value in the after_call callback" do
591
- return_value = :returns_value
592
- @definition.with_any_args.returns(return_value).after_call do |value|
593
- :after_call_value
585
+ actual_value = @object.foobar
586
+ actual_value.should === return_value
587
+ actual_value.should == {:foo => :bar}
594
588
  end
595
589
 
596
- actual_value = @object.foobar
597
- actual_value.should == :after_call_value
598
- end
590
+ it "receives the return value in the after_call callback" do
591
+ return_value = :returns_value
592
+ @definition.with_any_args.returns(return_value).after_call do |value|
593
+ :after_call_value
594
+ end
599
595
 
600
- it "allows after_call to mock the return value" do
601
- return_value = Object.new
602
- @definition.with_any_args.returns(return_value).after_call do |value|
603
- mock(value).inner_method(1) {:baz}
604
- value
596
+ actual_value = @object.foobar
597
+ actual_value.should == :after_call_value
605
598
  end
606
599
 
607
- @object.foobar.inner_method(1).should == :baz
608
- end
600
+ it "allows after_call to mock the return value" do
601
+ return_value = Object.new
602
+ @definition.with_any_args.returns(return_value).after_call do |value|
603
+ mock(value).inner_method(1) {:baz}
604
+ value
605
+ end
606
+
607
+ @object.foobar.inner_method(1).should == :baz
608
+ end
609
609
 
610
- it "raises an error when not passed a block" do
611
- proc do
612
- @definition.after_call
613
- end.should raise_error(ArgumentError, "after_call expects a block")
610
+ it "raises an error when not passed a block" do
611
+ proc do
612
+ @definition.after_call
613
+ end.should raise_error(ArgumentError, "after_call expects a block")
614
+ end
614
615
  end
615
- end
616
616
 
617
- describe DoubleDefinition, "#returns" do
618
- it_should_behave_like "RR::DoubleDefinition"
617
+ describe DoubleDefinition, "#returns" do
618
+ it_should_behave_like "RR::DoubleDefinition"
619
619
 
620
- it "returns DoubleDefinition" do
621
- @definition.returns {:baz}.should === @definition
622
- @definition.returns(:baz).should === @definition
623
- end
620
+ it "returns DoubleDefinition" do
621
+ @definition.returns {:baz}.should === @definition
622
+ @definition.returns(:baz).should === @definition
623
+ end
624
624
 
625
- it "sets the value of the method when passed a block" do
626
- @definition.with_any_args.returns {:baz}
627
- @object.foobar.should == :baz
628
- end
625
+ it "sets the value of the method when passed a block" do
626
+ @definition.with_any_args.returns {:baz}
627
+ @object.foobar.should == :baz
628
+ end
629
629
 
630
- it "sets the value of the method when passed an argument" do
631
- @definition.returns(:baz).with_no_args
632
- @object.foobar.should == :baz
633
- end
630
+ it "sets the value of the method when passed an argument" do
631
+ @definition.returns(:baz).with_no_args
632
+ @object.foobar.should == :baz
633
+ end
634
634
 
635
- it "returns false when passed false" do
636
- @definition.returns(false).with_any_args
637
- @object.foobar.should == false
638
- end
635
+ it "returns false when passed false" do
636
+ @definition.returns(false).with_any_args
637
+ @object.foobar.should == false
638
+ end
639
639
 
640
- it "raises an error when both argument and block is passed in" do
641
- proc do
642
- @definition.returns(:baz) {:another}
643
- end.should raise_error(ArgumentError, "returns cannot accept both an argument and a block")
640
+ it "raises an error when both argument and block is passed in" do
641
+ proc do
642
+ @definition.returns(:baz) {:another}
643
+ end.should raise_error(ArgumentError, "returns cannot accept both an argument and a block")
644
+ end
644
645
  end
645
- end
646
646
 
647
- describe DoubleDefinition, "#implemented_by" do
648
- it_should_behave_like "RR::DoubleDefinition"
647
+ describe DoubleDefinition, "#implemented_by" do
648
+ it_should_behave_like "RR::DoubleDefinition"
649
649
 
650
- it "returns the DoubleDefinition" do
651
- @definition.implemented_by(proc{:baz}).should === @definition
652
- end
650
+ it "returns the DoubleDefinition" do
651
+ @definition.implemented_by(proc{:baz}).should === @definition
652
+ end
653
653
 
654
- it "sets the implementation to the passed in proc" do
655
- @definition.implemented_by(proc{:baz}).with_no_args
656
- @object.foobar.should == :baz
657
- end
654
+ it "sets the implementation to the passed in proc" do
655
+ @definition.implemented_by(proc{:baz}).with_no_args
656
+ @object.foobar.should == :baz
657
+ end
658
658
 
659
- it "sets the implementation to the passed in method" do
660
- def @object.foobar(a, b)
661
- [b, a]
659
+ it "sets the implementation to the passed in method" do
660
+ def @object.foobar(a, b)
661
+ [b, a]
662
+ end
663
+ @definition.implemented_by(@object.method(:foobar))
664
+ @object.foobar(1, 2).should == [2, 1]
662
665
  end
663
- @definition.implemented_by(@object.method(:foobar))
664
- @object.foobar(1, 2).should == [2, 1]
665
666
  end
666
- end
667
667
 
668
- describe DoubleDefinition, "#implemented_by_original_method" do
669
- it_should_behave_like "RR::DoubleDefinition"
668
+ describe DoubleDefinition, "#implemented_by_original_method" do
669
+ it_should_behave_like "RR::DoubleDefinition"
670
670
 
671
- it "returns the DoubleDefinition object" do
672
- @definition.implemented_by_original_method.should === @definition
673
- end
671
+ it "returns the DoubleDefinition object" do
672
+ @definition.implemented_by_original_method.should === @definition
673
+ end
674
674
 
675
- it "sets the implementation to the original method" do
676
- @definition.implemented_by_original_method.with_any_args
677
- @object.foobar(1, 2).should == :original_return_value
678
- end
675
+ it "sets the implementation to the original method" do
676
+ @definition.implemented_by_original_method.with_any_args
677
+ @object.foobar(1, 2).should == :original_return_value
678
+ end
679
679
 
680
- it "calls method_missing when original_method does not exist" do
681
- class << @object
682
- def method_missing(method_name, *args, &block)
683
- "method_missing for #{method_name}(#{args.inspect})"
680
+ it "calls method_missing when original_method does not exist" do
681
+ class << @object
682
+ def method_missing(method_name, *args, &block)
683
+ "method_missing for #{method_name}(#{args.inspect})"
684
+ end
684
685
  end
685
- end
686
- double_injection = @space.double_injection(@object, :does_not_exist)
687
- double = @space.double(double_injection)
688
- double.with_any_args
689
- double.implemented_by_original_method
686
+ double_injection = @space.double_injection(@object, :does_not_exist)
687
+ double = @space.double(double_injection)
688
+ double.with_any_args
689
+ double.implemented_by_original_method
690
690
 
691
- return_value = @object.does_not_exist(1, 2)
692
- return_value.should == "method_missing for does_not_exist([1, 2])"
691
+ return_value = @object.does_not_exist(1, 2)
692
+ return_value.should == "method_missing for does_not_exist([1, 2])"
693
+ end
693
694
  end
694
- end
695
695
 
696
- describe DoubleDefinition, "#exact_match?" do
697
- it_should_behave_like "RR::DoubleDefinition"
696
+ describe DoubleDefinition, "#exact_match?" do
697
+ it_should_behave_like "RR::DoubleDefinition"
698
698
 
699
- it "returns false when no expectation set" do
700
- @definition.should_not be_exact_match()
701
- @definition.should_not be_exact_match(nil)
702
- @definition.should_not be_exact_match(Object.new)
703
- @definition.should_not be_exact_match(1, 2, 3)
704
- end
699
+ it "returns false when no expectation set" do
700
+ @definition.should_not be_exact_match()
701
+ @definition.should_not be_exact_match(nil)
702
+ @definition.should_not be_exact_match(Object.new)
703
+ @definition.should_not be_exact_match(1, 2, 3)
704
+ end
705
705
 
706
- it "returns false when arguments are not an exact match" do
707
- @definition.with(1, 2, 3)
708
- @definition.should_not be_exact_match(1, 2)
709
- @definition.should_not be_exact_match(1)
710
- @definition.should_not be_exact_match()
711
- @definition.should_not be_exact_match("does not match")
712
- end
706
+ it "returns false when arguments are not an exact match" do
707
+ @definition.with(1, 2, 3)
708
+ @definition.should_not be_exact_match(1, 2)
709
+ @definition.should_not be_exact_match(1)
710
+ @definition.should_not be_exact_match()
711
+ @definition.should_not be_exact_match("does not match")
712
+ end
713
713
 
714
- it "returns true when arguments are an exact match" do
715
- @definition.with(1, 2, 3)
716
- @definition.should be_exact_match(1, 2, 3)
714
+ it "returns true when arguments are an exact match" do
715
+ @definition.with(1, 2, 3)
716
+ @definition.should be_exact_match(1, 2, 3)
717
+ end
717
718
  end
718
- end
719
719
 
720
- describe DoubleDefinition, "#wildcard_match?" do
721
- it_should_behave_like "RR::DoubleDefinition"
720
+ describe DoubleDefinition, "#wildcard_match?" do
721
+ it_should_behave_like "RR::DoubleDefinition"
722
722
 
723
- it "returns false when no expectation set" do
724
- @definition.should_not be_wildcard_match()
725
- @definition.should_not be_wildcard_match(nil)
726
- @definition.should_not be_wildcard_match(Object.new)
727
- @definition.should_not be_wildcard_match(1, 2, 3)
728
- end
723
+ it "returns false when no expectation set" do
724
+ @definition.should_not be_wildcard_match()
725
+ @definition.should_not be_wildcard_match(nil)
726
+ @definition.should_not be_wildcard_match(Object.new)
727
+ @definition.should_not be_wildcard_match(1, 2, 3)
728
+ end
729
729
 
730
- it "returns true when arguments are an exact match" do
731
- @definition.with(1, 2, 3)
732
- @definition.should be_wildcard_match(1, 2, 3)
733
- @definition.should_not be_wildcard_match(1, 2)
734
- @definition.should_not be_wildcard_match(1)
735
- @definition.should_not be_wildcard_match()
736
- @definition.should_not be_wildcard_match("does not match")
737
- end
730
+ it "returns true when arguments are an exact match" do
731
+ @definition.with(1, 2, 3)
732
+ @definition.should be_wildcard_match(1, 2, 3)
733
+ @definition.should_not be_wildcard_match(1, 2)
734
+ @definition.should_not be_wildcard_match(1)
735
+ @definition.should_not be_wildcard_match()
736
+ @definition.should_not be_wildcard_match("does not match")
737
+ end
738
738
 
739
- it "returns true when with_any_args" do
740
- @definition.with_any_args
739
+ it "returns true when with_any_args" do
740
+ @definition.with_any_args
741
741
 
742
- @definition.should be_wildcard_match(1, 2, 3)
743
- @definition.should be_wildcard_match(1, 2)
744
- @definition.should be_wildcard_match(1)
745
- @definition.should be_wildcard_match()
746
- @definition.should be_wildcard_match("does not match")
742
+ @definition.should be_wildcard_match(1, 2, 3)
743
+ @definition.should be_wildcard_match(1, 2)
744
+ @definition.should be_wildcard_match(1)
745
+ @definition.should be_wildcard_match()
746
+ @definition.should be_wildcard_match("does not match")
747
+ end
747
748
  end
748
- end
749
749
 
750
- describe DoubleDefinition, "#terminal?" do
751
- it_should_behave_like "RR::DoubleDefinition"
750
+ describe DoubleDefinition, "#terminal?" do
751
+ it_should_behave_like "RR::DoubleDefinition"
752
752
 
753
- it "returns true when times_matcher's terminal? is true" do
754
- @definition.once
755
- @definition.times_matcher.should be_terminal
756
- @definition.should be_terminal
757
- end
753
+ it "returns true when times_matcher's terminal? is true" do
754
+ @definition.once
755
+ @definition.times_matcher.should be_terminal
756
+ @definition.should be_terminal
757
+ end
758
758
 
759
- it "returns false when times_matcher's terminal? is false" do
760
- @definition.any_number_of_times
761
- @definition.times_matcher.should_not be_terminal
762
- @definition.should_not be_terminal
763
- end
759
+ it "returns false when times_matcher's terminal? is false" do
760
+ @definition.any_number_of_times
761
+ @definition.times_matcher.should_not be_terminal
762
+ @definition.should_not be_terminal
763
+ end
764
764
 
765
- it "returns false when there is not times_matcher" do
766
- @definition.times_matcher.should be_nil
767
- @definition.should_not be_terminal
765
+ it "returns false when there is not times_matcher" do
766
+ @definition.times_matcher.should be_nil
767
+ @definition.should_not be_terminal
768
+ end
768
769
  end
769
- end
770
770
 
771
- describe DoubleDefinition, "#expected_arguments" do
772
- it_should_behave_like "RR::DoubleDefinition"
771
+ describe DoubleDefinition, "#expected_arguments" do
772
+ it_should_behave_like "RR::DoubleDefinition"
773
+
774
+ it "returns argument expectation's expected_arguments when there is a argument expectation" do
775
+ @definition.with(1, 2)
776
+ @definition.expected_arguments.should == [1, 2]
777
+ end
773
778
 
774
- it "returns argument expectation's expected_arguments when there is a argument expectation" do
775
- @definition.with(1, 2)
776
- @definition.expected_arguments.should == [1, 2]
779
+ it "returns an empty array when there is no argument expectation" do
780
+ @definition.argument_expectation.should be_nil
781
+ @definition.expected_arguments.should == []
782
+ end
777
783
  end
778
784
 
779
- it "returns an empty array when there is no argument expectation" do
780
- @definition.argument_expectation.should be_nil
781
- @definition.expected_arguments.should == []
785
+ describe DoubleDefinition, "#block_callback_strategy" do
786
+ it_should_behave_like "RR::DoubleDefinition"
787
+
788
+ it "defaults to :returns" do
789
+ @definition.block_callback_strategy.should == :returns
790
+ end
782
791
  end
783
- end
784
792
 
785
- describe DoubleDefinition, "#block_callback_strategy" do
786
- it_should_behave_like "RR::DoubleDefinition"
793
+ describe DoubleDefinition, "#returns_block_callback_strategy!" do
794
+ it_should_behave_like "RR::DoubleDefinition"
787
795
 
788
- it "defaults to :returns" do
789
- @definition.block_callback_strategy.should == :returns
796
+ it "sets the block_callback_strategy to :returns" do
797
+ @definition.returns_block_callback_strategy!
798
+ @definition.block_callback_strategy.should == :returns
799
+ end
790
800
  end
791
- end
792
801
 
793
- describe DoubleDefinition, "#returns_block_callback_strategy!" do
794
- it_should_behave_like "RR::DoubleDefinition"
802
+ describe DoubleDefinition, "#after_call_block_callback_strategy!" do
803
+ it_should_behave_like "RR::DoubleDefinition"
795
804
 
796
- it "sets the block_callback_strategy to :returns" do
797
- @definition.returns_block_callback_strategy!
798
- @definition.block_callback_strategy.should == :returns
805
+ it "sets the block_callback_strategy to :after_call" do
806
+ @definition.after_call_block_callback_strategy!
807
+ @definition.block_callback_strategy.should == :after_call
808
+ end
799
809
  end
800
- end
801
810
 
802
- describe DoubleDefinition, "#after_call_block_callback_strategy!" do
803
- it_should_behave_like "RR::DoubleDefinition"
811
+ describe DoubleDefinition, "#verbose" do
812
+ it_should_behave_like "RR::DoubleDefinition"
804
813
 
805
- it "sets the block_callback_strategy to :after_call" do
806
- @definition.after_call_block_callback_strategy!
807
- @definition.block_callback_strategy.should == :after_call
814
+ it "sets the verbose? to true" do
815
+ @definition.should_not be_verbose
816
+ @definition.verbose
817
+ @definition.should be_verbose
818
+ end
808
819
  end
809
- end
810
820
  end