caricature 0.7.6 → 0.7.7
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/caricature.gemspec +3 -3
- data/lib/bin/Workarounds.dll.mdb +0 -0
- data/lib/caricature.rb +25 -25
- data/lib/caricature/clr.rb +6 -6
- data/lib/caricature/clr/aspnet_mvc.rb +54 -54
- data/lib/caricature/core_ext.rb +10 -10
- data/lib/caricature/core_ext/array.rb +9 -9
- data/lib/caricature/core_ext/class.rb +31 -14
- data/lib/caricature/core_ext/hash.rb +12 -12
- data/lib/caricature/core_ext/module.rb +14 -14
- data/lib/caricature/core_ext/object.rb +76 -18
- data/lib/caricature/core_ext/string.rb +16 -16
- data/lib/caricature/core_ext/system/string.rb +20 -20
- data/lib/caricature/core_ext/system/type.rb +26 -26
- data/lib/caricature/descriptor.rb +73 -73
- data/lib/caricature/expectation.rb +264 -263
- data/lib/caricature/isolation.rb +143 -143
- data/lib/caricature/isolator.rb +302 -302
- data/lib/caricature/messenger.rb +67 -67
- data/lib/caricature/method_call_recorder.rb +228 -228
- data/lib/caricature/verification.rb +60 -60
- data/lib/caricature/version.rb +1 -1
- data/spec/bacon/integration/clr_to_clr_spec.rb +4 -4
- data/spec/bacon/integration/clr_to_ruby_spec.rb +227 -227
- data/spec/bacon/integration/event_spec.rb +2 -2
- data/spec/bacon/integration/ruby_to_ruby_spec.rb +270 -270
- data/spec/bacon/integration/syntax_spec.rb +43 -0
- data/spec/bacon/unit/core_ext_spec.rb +87 -87
- data/spec/bacon/unit/expectation_spec.rb +300 -300
- data/spec/bacon/unit/interop_spec.rb +29 -29
- data/spec/bacon/unit/isolation_spec.rb +86 -86
- data/spec/bacon/unit/isolator_spec.rb +219 -219
- data/spec/bacon/unit/messaging_spec.rb +310 -310
- data/spec/bacon/unit/method_call_spec.rb +342 -342
- data/spec/bin/ClrModels.dll.mdb +0 -0
- data/spec/rspec/unit/event_spec.rb +1 -1
- metadata +31 -11
- data/spec/models.notused/ClrModels.cs +0 -241
- data/spec/models.notused/ruby_models.rb +0 -151
@@ -1,343 +1,343 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "MethodCallRecorder" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@recorder = Caricature::MethodCallRecorder.new
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "when recording a call without arguments" do
|
10
|
-
|
11
|
-
before do
|
12
|
-
@recorder.record_call :my_method
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should have 1 method call" do
|
16
|
-
@recorder.method_calls[:instance].size.should.equal 1
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "recorded call" do
|
20
|
-
|
21
|
-
before do
|
22
|
-
@mc = @recorder.method_calls[:instance][:my_method]
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should have a method call collected" do
|
26
|
-
@mc.should.not.equal nil
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should have the correct name" do
|
30
|
-
@mc.method_name.should.equal :my_method
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should have no arguments" do
|
34
|
-
@mc.args.should.equal [Caricature::ArgumentRecording.new]
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should have no block" do
|
38
|
-
@mc.block.should.equal nil
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should have a count a 1" do
|
42
|
-
@mc.count.should.equal 1
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "when recording a call without arguments but with a block" do
|
50
|
-
|
51
|
-
before do
|
52
|
-
@block_content = "I'm in the block"
|
53
|
-
@recorder.record_call :my_method do
|
54
|
-
@block_content
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should have 1 method call" do
|
59
|
-
@recorder.method_calls[:instance].size.should.equal 1
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "recorded call" do
|
63
|
-
|
64
|
-
before do
|
65
|
-
@mc = @recorder.method_calls[:instance][:my_method]
|
66
|
-
end
|
67
|
-
|
68
|
-
it "should have a method call collected" do
|
69
|
-
@mc.should.not.equal nil
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should have the correct name" do
|
73
|
-
@mc.method_name.should.equal :my_method
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should have no arguments" do
|
77
|
-
@mc.args.should.equal [Caricature::ArgumentRecording.new]
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should have a block" do
|
81
|
-
@mc.args.first.block.should.not.equal nil
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should have the correct block" do
|
85
|
-
@mc.args.first.block.call.should.equal @block_content
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should have a count a 1" do
|
89
|
-
@mc.count.should.equal 1
|
90
|
-
end
|
91
|
-
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "when recording a call 1 argument" do
|
97
|
-
|
98
|
-
before do
|
99
|
-
@recorder.record_call :my_method, :instance, nil, 1
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should have 1 method call" do
|
103
|
-
@recorder.method_calls[:instance].size.should.equal 1
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "recorded call" do
|
107
|
-
|
108
|
-
before do
|
109
|
-
@mc = @recorder.method_calls[:instance][:my_method]
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should have a method call collected" do
|
113
|
-
@mc.should.not.equal nil
|
114
|
-
end
|
115
|
-
|
116
|
-
it "should have the correct name" do
|
117
|
-
@mc.method_name.should.equal :my_method
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should have 1 argument" do
|
121
|
-
@mc.args.size.should.equal 1
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should have the correct argument" do
|
125
|
-
@mc.args.should.equal [Caricature::ArgumentRecording.new([1])]
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should have no block" do
|
129
|
-
@mc.block.should.equal nil
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should have a count a 1" do
|
133
|
-
@mc.count.should.equal 1
|
134
|
-
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "when recording a call 2 arguments" do
|
141
|
-
|
142
|
-
before do
|
143
|
-
@recorder.record_call :my_method, :instance, nil, 1, 2
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should have 1 method call" do
|
147
|
-
@recorder.method_calls[:instance].size.should.equal 1
|
148
|
-
end
|
149
|
-
|
150
|
-
describe "recorded call" do
|
151
|
-
|
152
|
-
before do
|
153
|
-
@mc = @recorder.method_calls[:instance][:my_method]
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should have a method call collected" do
|
157
|
-
@mc.should.not.equal nil
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should have the correct name" do
|
161
|
-
@mc.method_name.should.equal :my_method
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should have 1 argument recording" do
|
165
|
-
@mc.args.size.should.equal 1
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should have the correct arguments" do
|
169
|
-
@mc.args.should.equal [Caricature::ArgumentRecording.new([1, 2])]
|
170
|
-
end
|
171
|
-
|
172
|
-
it "should have no block" do
|
173
|
-
@mc.block.should.equal nil
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should have a count a 1" do
|
177
|
-
@mc.count.should.equal 1
|
178
|
-
end
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
describe "when recording 2 calls with no arguments" do
|
185
|
-
|
186
|
-
before do
|
187
|
-
@recorder.record_call :my_method
|
188
|
-
@recorder.record_call :my_method
|
189
|
-
end
|
190
|
-
|
191
|
-
it "should have 1 method call" do
|
192
|
-
@recorder.method_calls[:instance].size.should.equal 1
|
193
|
-
end
|
194
|
-
|
195
|
-
describe "recorded call" do
|
196
|
-
|
197
|
-
before do
|
198
|
-
@mc = @recorder.method_calls[:instance][:my_method]
|
199
|
-
end
|
200
|
-
|
201
|
-
it "should have a method call collected" do
|
202
|
-
@mc.should.not.equal nil
|
203
|
-
end
|
204
|
-
|
205
|
-
it "should have the correct name" do
|
206
|
-
@mc.method_name.should.equal :my_method
|
207
|
-
end
|
208
|
-
|
209
|
-
it "should have no arguments" do
|
210
|
-
@mc.args.should.equal [Caricature::ArgumentRecording.new]
|
211
|
-
end
|
212
|
-
|
213
|
-
it "should have no block" do
|
214
|
-
@mc.block.should.equal nil
|
215
|
-
end
|
216
|
-
|
217
|
-
it "should have a count of 2" do
|
218
|
-
@mc.count.should.equal 2
|
219
|
-
end
|
220
|
-
|
221
|
-
end
|
222
|
-
|
223
|
-
end
|
224
|
-
|
225
|
-
describe "when recording a call with a block" do
|
226
|
-
before do
|
227
|
-
@args = []
|
228
|
-
@b = @recorder.record_call :some_method, :instance, nil, 5, 6, 7 do |*args|
|
229
|
-
@args = args
|
230
|
-
end
|
231
|
-
|
232
|
-
end
|
233
|
-
|
234
|
-
it "should return a block" do
|
235
|
-
@b.should.not.be.nil
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should return a block that wraps a recording" do
|
239
|
-
@b.call 8, 9, 0
|
240
|
-
@recorder.method_calls[:instance][:some_method].args.first.blocks.first.args.should.equal [8, 9, 0]
|
241
|
-
end
|
242
|
-
|
243
|
-
it "should call the original block" do
|
244
|
-
@b.call 8, 9, 0
|
245
|
-
@args.should.equal [8, 9, 0]
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
describe "when recording 2 calls with different arguments" do
|
250
|
-
|
251
|
-
before do
|
252
|
-
@recorder.record_call :my_method
|
253
|
-
@recorder.record_call :my_method, :instance, nil, 1, 3, 4
|
254
|
-
end
|
255
|
-
|
256
|
-
it "should have 1 method call" do
|
257
|
-
@recorder.method_calls[:instance].size.should.equal 1
|
258
|
-
end
|
259
|
-
|
260
|
-
describe "recorded call" do
|
261
|
-
|
262
|
-
before do
|
263
|
-
@mc = @recorder.method_calls[:instance][:my_method]
|
264
|
-
end
|
265
|
-
|
266
|
-
it "should have a method call collected" do
|
267
|
-
@mc.should.not.equal nil
|
268
|
-
end
|
269
|
-
|
270
|
-
it "should have the correct name" do
|
271
|
-
@mc.method_name.should.equal :my_method
|
272
|
-
end
|
273
|
-
|
274
|
-
it "should have argument variations" do
|
275
|
-
@mc.has_argument_variations?.should.be.true?
|
276
|
-
end
|
277
|
-
|
278
|
-
it "should have no block" do
|
279
|
-
@mc.block.should.equal nil
|
280
|
-
end
|
281
|
-
|
282
|
-
it "should have a count of 2" do
|
283
|
-
@mc.count.should.equal 2
|
284
|
-
end
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
end
|
289
|
-
|
290
|
-
describe "when asked if a certain method was called" do
|
291
|
-
|
292
|
-
before do
|
293
|
-
@recorder.record_call :my_method
|
294
|
-
@recorder.record_call :my_method, :instance, nil, 1, 3, 4
|
295
|
-
|
296
|
-
end
|
297
|
-
|
298
|
-
it "should confirm when we don't care about the arguments" do
|
299
|
-
@recorder.was_called?(:my_method, nil, :instance, :any).should.be.true?
|
300
|
-
end
|
301
|
-
|
302
|
-
it "should confirm when there are no argument variations" do
|
303
|
-
@recorder.record_call :another_method
|
304
|
-
@recorder.was_called?(:another_method, nil, :instance, :any).should.be.true?
|
305
|
-
end
|
306
|
-
|
307
|
-
it "should be negative when we provide the wrong arguments" do
|
308
|
-
@recorder.was_called?(:my_method, nil, :instance, 1, 2, 5).should.be.false?
|
309
|
-
end
|
310
|
-
|
311
|
-
it "should be positive when we provide the correct arguments" do
|
312
|
-
@recorder.was_called?(:my_method, nil, :instance, 1, 3, 4).should.be.true?
|
313
|
-
end
|
314
|
-
|
315
|
-
it "should be positive when we provide no arguments and a call had been recorded without arguments" do
|
316
|
-
@recorder.was_called?(:my_method, nil, :instance).should.be.true?
|
317
|
-
end
|
318
|
-
|
319
|
-
describe "with block" do
|
320
|
-
|
321
|
-
before do
|
322
|
-
@args = []
|
323
|
-
b = @recorder.record_call :some_method, :instance, nil, 5, 6, 7 do |*args|
|
324
|
-
@args << args
|
325
|
-
end
|
326
|
-
b.call 1, 3, 5
|
327
|
-
b.call 3, 4, 6
|
328
|
-
b.call
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should be positive when we provide any arguments" do
|
332
|
-
@recorder.was_called?(:some_method, [:any], :instance, :any).should.be.true?
|
333
|
-
end
|
334
|
-
|
335
|
-
it "should be positive when we provide specific arguments" do
|
336
|
-
@recorder.was_called?(:some_method, [1, 3, 5], :instance, :any).should.be.true?
|
337
|
-
end
|
338
|
-
|
339
|
-
end
|
340
|
-
|
341
|
-
end
|
342
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "MethodCallRecorder" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@recorder = Caricature::MethodCallRecorder.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "when recording a call without arguments" do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@recorder.record_call :my_method
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should have 1 method call" do
|
16
|
+
@recorder.method_calls[:instance].size.should.equal 1
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "recorded call" do
|
20
|
+
|
21
|
+
before do
|
22
|
+
@mc = @recorder.method_calls[:instance][:my_method]
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have a method call collected" do
|
26
|
+
@mc.should.not.equal nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have the correct name" do
|
30
|
+
@mc.method_name.should.equal :my_method
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have no arguments" do
|
34
|
+
@mc.args.should.equal [Caricature::ArgumentRecording.new]
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have no block" do
|
38
|
+
@mc.block.should.equal nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have a count a 1" do
|
42
|
+
@mc.count.should.equal 1
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "when recording a call without arguments but with a block" do
|
50
|
+
|
51
|
+
before do
|
52
|
+
@block_content = "I'm in the block"
|
53
|
+
@recorder.record_call :my_method do
|
54
|
+
@block_content
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should have 1 method call" do
|
59
|
+
@recorder.method_calls[:instance].size.should.equal 1
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "recorded call" do
|
63
|
+
|
64
|
+
before do
|
65
|
+
@mc = @recorder.method_calls[:instance][:my_method]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should have a method call collected" do
|
69
|
+
@mc.should.not.equal nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should have the correct name" do
|
73
|
+
@mc.method_name.should.equal :my_method
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should have no arguments" do
|
77
|
+
@mc.args.should.equal [Caricature::ArgumentRecording.new]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should have a block" do
|
81
|
+
@mc.args.first.block.should.not.equal nil
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should have the correct block" do
|
85
|
+
@mc.args.first.block.call.should.equal @block_content
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should have a count a 1" do
|
89
|
+
@mc.count.should.equal 1
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "when recording a call 1 argument" do
|
97
|
+
|
98
|
+
before do
|
99
|
+
@recorder.record_call :my_method, :instance, nil, 1
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should have 1 method call" do
|
103
|
+
@recorder.method_calls[:instance].size.should.equal 1
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "recorded call" do
|
107
|
+
|
108
|
+
before do
|
109
|
+
@mc = @recorder.method_calls[:instance][:my_method]
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should have a method call collected" do
|
113
|
+
@mc.should.not.equal nil
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should have the correct name" do
|
117
|
+
@mc.method_name.should.equal :my_method
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should have 1 argument" do
|
121
|
+
@mc.args.size.should.equal 1
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should have the correct argument" do
|
125
|
+
@mc.args.should.equal [Caricature::ArgumentRecording.new([1])]
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should have no block" do
|
129
|
+
@mc.block.should.equal nil
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should have a count a 1" do
|
133
|
+
@mc.count.should.equal 1
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
describe "when recording a call 2 arguments" do
|
141
|
+
|
142
|
+
before do
|
143
|
+
@recorder.record_call :my_method, :instance, nil, 1, 2
|
144
|
+
end
|
145
|
+
|
146
|
+
it "should have 1 method call" do
|
147
|
+
@recorder.method_calls[:instance].size.should.equal 1
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "recorded call" do
|
151
|
+
|
152
|
+
before do
|
153
|
+
@mc = @recorder.method_calls[:instance][:my_method]
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should have a method call collected" do
|
157
|
+
@mc.should.not.equal nil
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should have the correct name" do
|
161
|
+
@mc.method_name.should.equal :my_method
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should have 1 argument recording" do
|
165
|
+
@mc.args.size.should.equal 1
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should have the correct arguments" do
|
169
|
+
@mc.args.should.equal [Caricature::ArgumentRecording.new([1, 2])]
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should have no block" do
|
173
|
+
@mc.block.should.equal nil
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should have a count a 1" do
|
177
|
+
@mc.count.should.equal 1
|
178
|
+
end
|
179
|
+
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
describe "when recording 2 calls with no arguments" do
|
185
|
+
|
186
|
+
before do
|
187
|
+
@recorder.record_call :my_method
|
188
|
+
@recorder.record_call :my_method
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should have 1 method call" do
|
192
|
+
@recorder.method_calls[:instance].size.should.equal 1
|
193
|
+
end
|
194
|
+
|
195
|
+
describe "recorded call" do
|
196
|
+
|
197
|
+
before do
|
198
|
+
@mc = @recorder.method_calls[:instance][:my_method]
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should have a method call collected" do
|
202
|
+
@mc.should.not.equal nil
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should have the correct name" do
|
206
|
+
@mc.method_name.should.equal :my_method
|
207
|
+
end
|
208
|
+
|
209
|
+
it "should have no arguments" do
|
210
|
+
@mc.args.should.equal [Caricature::ArgumentRecording.new]
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should have no block" do
|
214
|
+
@mc.block.should.equal nil
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should have a count of 2" do
|
218
|
+
@mc.count.should.equal 2
|
219
|
+
end
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
describe "when recording a call with a block" do
|
226
|
+
before do
|
227
|
+
@args = []
|
228
|
+
@b = @recorder.record_call :some_method, :instance, nil, 5, 6, 7 do |*args|
|
229
|
+
@args = args
|
230
|
+
end
|
231
|
+
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should return a block" do
|
235
|
+
@b.should.not.be.nil
|
236
|
+
end
|
237
|
+
|
238
|
+
it "should return a block that wraps a recording" do
|
239
|
+
@b.call 8, 9, 0
|
240
|
+
@recorder.method_calls[:instance][:some_method].args.first.blocks.first.args.should.equal [8, 9, 0]
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should call the original block" do
|
244
|
+
@b.call 8, 9, 0
|
245
|
+
@args.should.equal [8, 9, 0]
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
describe "when recording 2 calls with different arguments" do
|
250
|
+
|
251
|
+
before do
|
252
|
+
@recorder.record_call :my_method
|
253
|
+
@recorder.record_call :my_method, :instance, nil, 1, 3, 4
|
254
|
+
end
|
255
|
+
|
256
|
+
it "should have 1 method call" do
|
257
|
+
@recorder.method_calls[:instance].size.should.equal 1
|
258
|
+
end
|
259
|
+
|
260
|
+
describe "recorded call" do
|
261
|
+
|
262
|
+
before do
|
263
|
+
@mc = @recorder.method_calls[:instance][:my_method]
|
264
|
+
end
|
265
|
+
|
266
|
+
it "should have a method call collected" do
|
267
|
+
@mc.should.not.equal nil
|
268
|
+
end
|
269
|
+
|
270
|
+
it "should have the correct name" do
|
271
|
+
@mc.method_name.should.equal :my_method
|
272
|
+
end
|
273
|
+
|
274
|
+
it "should have argument variations" do
|
275
|
+
@mc.has_argument_variations?.should.be.true?
|
276
|
+
end
|
277
|
+
|
278
|
+
it "should have no block" do
|
279
|
+
@mc.block.should.equal nil
|
280
|
+
end
|
281
|
+
|
282
|
+
it "should have a count of 2" do
|
283
|
+
@mc.count.should.equal 2
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
describe "when asked if a certain method was called" do
|
291
|
+
|
292
|
+
before do
|
293
|
+
@recorder.record_call :my_method
|
294
|
+
@recorder.record_call :my_method, :instance, nil, 1, 3, 4
|
295
|
+
|
296
|
+
end
|
297
|
+
|
298
|
+
it "should confirm when we don't care about the arguments" do
|
299
|
+
@recorder.was_called?(:my_method, nil, :instance, :any).should.be.true?
|
300
|
+
end
|
301
|
+
|
302
|
+
it "should confirm when there are no argument variations" do
|
303
|
+
@recorder.record_call :another_method
|
304
|
+
@recorder.was_called?(:another_method, nil, :instance, :any).should.be.true?
|
305
|
+
end
|
306
|
+
|
307
|
+
it "should be negative when we provide the wrong arguments" do
|
308
|
+
@recorder.was_called?(:my_method, nil, :instance, 1, 2, 5).should.be.false?
|
309
|
+
end
|
310
|
+
|
311
|
+
it "should be positive when we provide the correct arguments" do
|
312
|
+
@recorder.was_called?(:my_method, nil, :instance, 1, 3, 4).should.be.true?
|
313
|
+
end
|
314
|
+
|
315
|
+
it "should be positive when we provide no arguments and a call had been recorded without arguments" do
|
316
|
+
@recorder.was_called?(:my_method, nil, :instance).should.be.true?
|
317
|
+
end
|
318
|
+
|
319
|
+
describe "with block" do
|
320
|
+
|
321
|
+
before do
|
322
|
+
@args = []
|
323
|
+
b = @recorder.record_call :some_method, :instance, nil, 5, 6, 7 do |*args|
|
324
|
+
@args << args
|
325
|
+
end
|
326
|
+
b.call 1, 3, 5
|
327
|
+
b.call 3, 4, 6
|
328
|
+
b.call
|
329
|
+
end
|
330
|
+
|
331
|
+
it "should be positive when we provide any arguments" do
|
332
|
+
@recorder.was_called?(:some_method, [:any], :instance, :any).should.be.true?
|
333
|
+
end
|
334
|
+
|
335
|
+
it "should be positive when we provide specific arguments" do
|
336
|
+
@recorder.was_called?(:some_method, [1, 3, 5], :instance, :any).should.be.true?
|
337
|
+
end
|
338
|
+
|
339
|
+
end
|
340
|
+
|
341
|
+
end
|
342
|
+
|
343
343
|
end
|