caricature 0.7.5 → 0.7.6
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/README.rdoc +97 -97
- data/Rakefile +309 -310
- data/caricature.gemspec +123 -110
- data/lib/caricature/bacon/integration.rb +75 -75
- data/lib/caricature/bacon.rb +2 -2
- data/lib/caricature/clr/descriptor.rb +159 -159
- data/lib/caricature/clr/event_verification.rb +56 -56
- data/lib/caricature/clr/expectation.rb +100 -100
- data/lib/caricature/clr/isolation.rb +78 -78
- data/lib/caricature/clr/isolator.rb +252 -252
- data/lib/caricature/clr/messenger.rb +51 -49
- data/lib/caricature/clr/method_call_recorder.rb +96 -96
- data/lib/caricature/expectation.rb +1 -1
- data/lib/caricature/method_call_recorder.rb +3 -3
- data/lib/caricature/rspec/integration.rb +118 -118
- data/lib/caricature/version.rb +5 -5
- data/lib/caricature.rb +25 -25
- data/spec/bacon/integration/callback_spec.rb +156 -156
- data/spec/bacon/integration/clr_to_clr_spec.rb +325 -253
- data/spec/bacon/integration/event_spec.rb +97 -97
- data/spec/bacon/integration/indexer_spec.rb +27 -27
- data/spec/bacon/spec_helper.rb +4 -4
- data/spec/bacon/unit/descriptor_spec.rb +212 -212
- data/spec/bacon/unit/sword_spec.rb +39 -39
- data/spec/bacon/unit/verification_spec.rb +103 -103
- data/spec/bin/ClrModels.dll +0 -0
- data/spec/bin/ClrModels.dll.mdb +0 -0
- data/spec/fixtures/ExplodingCar.cs +56 -0
- data/spec/fixtures/ExposedChangedSubscriber.cs +26 -0
- data/spec/fixtures/ExposingWarrior.cs +58 -0
- data/spec/fixtures/IExplodingWarrior.cs +10 -0
- data/spec/fixtures/IExposing.cs +9 -0
- data/spec/fixtures/IExposingBridge.cs +9 -0
- data/spec/fixtures/IExposingWarrior.cs +8 -0
- data/spec/fixtures/IHaveAnIndexer.cs +8 -0
- data/spec/fixtures/IWarrior.cs +13 -0
- data/spec/fixtures/IWeapon.cs +9 -0
- data/spec/fixtures/IndexerCaller.cs +17 -0
- data/spec/fixtures/IndexerContained.cs +20 -0
- data/spec/fixtures/MyClassWithAStatic.cs +16 -0
- data/spec/fixtures/Ninja.cs +34 -0
- data/spec/fixtures/Samurai.cs +29 -0
- data/spec/fixtures/StaticCaller.cs +12 -0
- data/spec/fixtures/Sword.cs +16 -0
- data/spec/fixtures/SwordWithStatics.cs +19 -0
- data/spec/fixtures/clr_interaction.rb +61 -0
- data/spec/fixtures/dagger.rb +11 -0
- data/spec/fixtures/dagger_with_class_members.rb +11 -0
- data/spec/fixtures/sheath.rb +19 -0
- data/spec/fixtures/soldier.rb +29 -0
- data/spec/fixtures/soldier_with_class_members.rb +7 -0
- data/spec/fixtures/swift_cleanup_crew.rb +21 -0
- data/spec/fixtures/with_class_methods.rb +11 -0
- data/spec/{models → models.notused}/ClrModels.cs +241 -241
- data/spec/{models → models.notused}/ruby_models.rb +150 -150
- data/spec/rspec/integration/callback_spec.rb +156 -156
- data/spec/rspec/integration/clr_to_clr_spec.rb +254 -254
- data/spec/rspec/integration/clr_to_ruby_spec.rb +227 -227
- data/spec/rspec/integration/indexer_spec.rb +27 -27
- data/spec/rspec/integration/ruby_to_ruby_spec.rb +271 -271
- data/spec/rspec/spec_helper.rb +12 -12
- data/spec/rspec/unit/core_ext_spec.rb +87 -87
- data/spec/rspec/unit/descriptor_spec.rb +210 -210
- data/spec/rspec/unit/event_spec.rb +16 -16
- data/spec/rspec/unit/expectation_spec.rb +300 -300
- data/spec/rspec/unit/interop_spec.rb +29 -29
- data/spec/rspec/unit/isolation_spec.rb +86 -86
- data/spec/rspec/unit/isolator_spec.rb +219 -219
- data/spec/rspec/unit/messaging_spec.rb +310 -310
- data/spec/rspec/unit/method_call_spec.rb +342 -342
- data/spec/rspec/unit/sword_spec.rb +39 -39
- data/spec/rspec/unit/verification_spec.rb +103 -103
- data/spec/spec_helper.rb +16 -15
- metadata +42 -11
@@ -1,254 +1,326 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
@
|
162
|
-
end
|
163
|
-
|
164
|
-
it "should work
|
165
|
-
@
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
end
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
shared 'camel cased naming interceptions' do
|
4
|
+
|
5
|
+
it "should work without expectations" do
|
6
|
+
@ninja.attack ClrModels::Ninja.new, @weapon
|
7
|
+
|
8
|
+
@weapon.should.have_received?(:Attack)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should work for expectations with an argument constraint" do
|
12
|
+
ninja = ClrModels::Ninja.new
|
13
|
+
@weapon.when_receiving(:Attack).with(ninja).return(5)
|
14
|
+
|
15
|
+
@ninja.attack(ninja, @weapon).should.equal 5
|
16
|
+
|
17
|
+
@weapon.should.have_received?(:Attack) { |ver| ver.with(:any) }
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should work for expectations with an argument constraint when a wrong argument is passed in" do
|
21
|
+
@weapon.when_receiving(:Attack).with(ClrModels::Ninja.new).return(5)
|
22
|
+
|
23
|
+
@ninja.attack(ClrModels::Ninja.new, @weapon).should.equal 0
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should work for expectations with an argument constraint and an assertion argument constraint" do
|
27
|
+
ninja = ClrModels::Ninja.new
|
28
|
+
@weapon.when_receiving(:Attack).with(ninja).return(5)
|
29
|
+
|
30
|
+
@ninja.attack(ninja, @weapon).should.equal 5
|
31
|
+
|
32
|
+
@weapon.should.have_received?(:Attack) { |v| v.with(ninja) }
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should fail for expectations with an argument constraint and an assertion argument constraint" do
|
36
|
+
ninja = ClrModels::Ninja.new
|
37
|
+
@weapon.when_receiving(:Attack).with(ninja).return(5)
|
38
|
+
|
39
|
+
@ninja.attack(ninja, @weapon).should.equal 5
|
40
|
+
|
41
|
+
@weapon.should.not.have_received?(:Attack){ |v| v.with(ClrModels::Ninja.new) }
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should work with an expectation with any arguments" do
|
45
|
+
@weapon.when_receiving(:Damage).return(5)
|
46
|
+
|
47
|
+
@ninja.is_killed_by(@weapon).should.be.true?
|
48
|
+
@weapon.should.have_received?(:Damage)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should work with an expectation getting different method call result" do
|
52
|
+
@weapon.when_receiving(:Damage).return(2)
|
53
|
+
|
54
|
+
@ninja.is_killed_by(@weapon).should.be.false?
|
55
|
+
@weapon.should.have_received?(:Damage)
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should work for an assertion on a specific argument" do
|
59
|
+
@weapon.when_receiving(:Damage).return(2)
|
60
|
+
|
61
|
+
@ninja.is_killed_by(@weapon).should.be.false?
|
62
|
+
@weapon.should.have_received?(:Damage)
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "CLR to CLR interactions" do
|
68
|
+
|
69
|
+
describe "when using camel cased names" do
|
70
|
+
|
71
|
+
before do
|
72
|
+
@ninja = ClrModels::Ninja.new
|
73
|
+
@weapon = isolate ClrModels::IWeapon
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
behaves_like 'camel cased naming interceptions'
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "when isolating CLR interfaces" do
|
82
|
+
before do
|
83
|
+
@ninja = ClrModels::Ninja.new
|
84
|
+
@weapon = isolate ClrModels::IWeapon
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should work without expectations" do
|
88
|
+
@ninja.attack ClrModels::Ninja.new, @weapon
|
89
|
+
|
90
|
+
@weapon.should.have_received?(:attack)
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should work for expectations with an argument constraint" do
|
94
|
+
ninja = ClrModels::Ninja.new
|
95
|
+
@weapon.when_receiving(:attack).with(ninja).return(5)
|
96
|
+
|
97
|
+
@ninja.attack(ninja, @weapon).should.equal 5
|
98
|
+
|
99
|
+
@weapon.should.have_received?(:attack) { |ver| ver.with(:any) }
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should work for expectations with an argument constraint when a wrong argument is passed in" do
|
103
|
+
@weapon.when_receiving(:attack).with(ClrModels::Ninja.new).return(5)
|
104
|
+
|
105
|
+
@ninja.attack(ClrModels::Ninja.new, @weapon).should.equal 0
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should work for expectations with an argument constraint and an assertion argument constraint" do
|
109
|
+
ninja = ClrModels::Ninja.new
|
110
|
+
@weapon.when_receiving(:attack).with(ninja).return(5)
|
111
|
+
|
112
|
+
@ninja.attack(ninja, @weapon).should.equal 5
|
113
|
+
|
114
|
+
@weapon.should.have_received?(:attack) { |v| v.with(ninja) }
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should fail for expectations with an argument constraint and an assertion argument constraint" do
|
118
|
+
ninja = ClrModels::Ninja.new
|
119
|
+
@weapon.when_receiving(:attack).with(ninja).return(5)
|
120
|
+
|
121
|
+
@ninja.attack(ninja, @weapon).should.equal 5
|
122
|
+
|
123
|
+
@weapon.should.not.have_received?(:attack){ |v| v.with(ClrModels::Ninja.new) }
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should work with an expectation with any arguments" do
|
127
|
+
@weapon.when_receiving(:damage).return(5)
|
128
|
+
|
129
|
+
@ninja.is_killed_by(@weapon).should.be.true?
|
130
|
+
@weapon.should.have_received?(:damage)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should work with an expectation getting different method call result" do
|
134
|
+
@weapon.when_receiving(:damage).return(2)
|
135
|
+
|
136
|
+
@ninja.is_killed_by(@weapon).should.be.false?
|
137
|
+
@weapon.should.have_received?(:damage)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should work for an assertion on a specific argument" do
|
141
|
+
@weapon.when_receiving(:damage).return(2)
|
142
|
+
|
143
|
+
@ninja.is_killed_by(@weapon).should.be.false?
|
144
|
+
@weapon.should.have_received?(:damage)
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
describe "when isolating CLR classes" do
|
150
|
+
|
151
|
+
describe "plain vanilla CLR classes" do
|
152
|
+
before do
|
153
|
+
@weapon = ClrModels::Sword.new
|
154
|
+
@ninja = isolate ClrModels::Ninja
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should work without expectations" do
|
158
|
+
result = @weapon.attack @ninja
|
159
|
+
result.should.equal 0
|
160
|
+
|
161
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(@weapon) }
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should work for expectations with an argument constraint" do
|
165
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
166
|
+
|
167
|
+
@weapon.attack(@ninja).should.equal 5
|
168
|
+
|
169
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(:any) }
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should work for expectations with an argument constraint when a wrong argument is passed in" do
|
173
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
174
|
+
|
175
|
+
@weapon.attack(ClrModels::Ninja.new).should.equal 6
|
176
|
+
|
177
|
+
@ninja.should.not.have_received?(:survive_attack_with) { |v| v.with(@weapon) }
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should work for expectations with an argument constraint and an assertion argument constraint" do
|
181
|
+
ninja = ClrModels::Ninja.new
|
182
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
183
|
+
|
184
|
+
@weapon.attack(@ninja).should.equal 5
|
185
|
+
|
186
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(@weapon) }
|
187
|
+
end
|
188
|
+
|
189
|
+
it "should fail for expectations with an argument constraint and an assertion argument constraint" do
|
190
|
+
ninja = ClrModels::Ninja.new
|
191
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
192
|
+
|
193
|
+
@weapon.attack(@ninja).should.equal 5
|
194
|
+
|
195
|
+
@ninja.should.not.have_received?(:survive_attack_with) { |v| v.with(ClrModels::Sword.new) }
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should work with an expectation for any arguments" do
|
199
|
+
@ninja.when_receiving(:survive_attack_with).return(5)
|
200
|
+
|
201
|
+
result = @weapon.attack @ninja
|
202
|
+
result.should.equal 5
|
203
|
+
|
204
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(:any) }
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should work with an assertion for specific arguments" do
|
208
|
+
@ninja.when_receiving(:survive_attack_with) do |method_should|
|
209
|
+
method_should.return(5)
|
210
|
+
end
|
211
|
+
|
212
|
+
result = @weapon.attack @ninja
|
213
|
+
result.should.equal 5
|
214
|
+
|
215
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(@weapon) }
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should fail for an assertion with wrong arguments" do
|
219
|
+
@ninja.when_receiving(:survive_attack_with) do |method_should|
|
220
|
+
method_should.return(5)
|
221
|
+
end
|
222
|
+
|
223
|
+
result = @weapon.attack @ninja
|
224
|
+
result.should.equal 5
|
225
|
+
|
226
|
+
@ninja.should.not.have_received?(:survive_attack_with) {|v| v.with(isolate(ClrModels::IWeapon)) }
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
# describe "that have an indexer" do
|
232
|
+
# before do
|
233
|
+
# @cons = ClrModels::IndexerCaller.new
|
234
|
+
# @ind = Caricature::Isolation.for(ClrModels::IndexerContained)
|
235
|
+
# end
|
236
|
+
#
|
237
|
+
# it "should work without expectations" do
|
238
|
+
# @cons.call_index_on_class(@ind, "key1").should.be.nil
|
239
|
+
# end
|
240
|
+
#
|
241
|
+
#
|
242
|
+
# end
|
243
|
+
|
244
|
+
end
|
245
|
+
|
246
|
+
describe "when isolating CLR instances" do
|
247
|
+
|
248
|
+
before do
|
249
|
+
@weapon = ClrModels::Sword.new
|
250
|
+
@ninja = Caricature::Isolation.for(ClrModels::Ninja.new)
|
251
|
+
end
|
252
|
+
|
253
|
+
it "should work without expectations" do
|
254
|
+
result = @weapon.attack @ninja
|
255
|
+
result.should.equal 0
|
256
|
+
|
257
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(@weapon) }
|
258
|
+
end
|
259
|
+
|
260
|
+
it "should work for expectations with an argument constraint" do
|
261
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
262
|
+
|
263
|
+
@weapon.attack(@ninja).should.equal 5
|
264
|
+
|
265
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(:any) }
|
266
|
+
end
|
267
|
+
|
268
|
+
it "should work for expectations with an argument constraint when a wrong argument is passed in" do
|
269
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
270
|
+
|
271
|
+
@weapon.attack(ClrModels::Ninja.new).should.equal 6
|
272
|
+
|
273
|
+
@ninja.should.not.have_received?(:survive_attack_with){ |v| v.with(@weapon) }
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should work for expectations with an argument constraint and an assertion argument constraint" do
|
277
|
+
ninja = ClrModels::Ninja.new
|
278
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
279
|
+
|
280
|
+
@weapon.attack(@ninja).should.equal 5
|
281
|
+
|
282
|
+
@ninja.did_receive?(:survive_attack_with).with(@weapon).should.be.successful
|
283
|
+
end
|
284
|
+
|
285
|
+
it "should fail for expectations with an argument constraint and an assertion argument constraint" do
|
286
|
+
ninja = ClrModels::Ninja.new
|
287
|
+
@ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
|
288
|
+
|
289
|
+
@weapon.attack(@ninja).should.equal 5
|
290
|
+
|
291
|
+
@ninja.did_receive?(:survive_attack_with).with(ClrModels::Sword.new).should.not.be.successful
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should work with an expectation for any arguments" do
|
295
|
+
@ninja.when_receiving(:survive_attack_with).return(5)
|
296
|
+
|
297
|
+
result = @weapon.attack @ninja
|
298
|
+
result.should.equal 5
|
299
|
+
|
300
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(:any) }
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should fail for an assertion for specific arguments" do
|
304
|
+
@ninja.when_receiving(:survive_attack_with) do |method_should|
|
305
|
+
method_should.return(5)
|
306
|
+
end
|
307
|
+
|
308
|
+
result = @weapon.attack @ninja
|
309
|
+
result.should.equal 5
|
310
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(:any) }
|
311
|
+
@ninja.should.have_received?(:survive_attack_with) { |v| v.with(@weapon) }
|
312
|
+
end
|
313
|
+
|
314
|
+
it "should allow to delegate the method call to the real instance (partial mock)" do
|
315
|
+
@ninja.when_receiving(:survive_attack_with).super_after
|
316
|
+
|
317
|
+
result = @weapon.attack @ninja
|
318
|
+
result.should.equal 6
|
319
|
+
|
320
|
+
@ninja.should.have_received?(:survive_attack_with)
|
321
|
+
end
|
322
|
+
|
323
|
+
|
324
|
+
end
|
325
|
+
|
254
326
|
end
|