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,301 +1,301 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "Caricature::Expectations" do
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
describe "Caricature::ExpectationBuilder" do
|
8
|
-
|
9
|
-
it "should create an expectation builder" do
|
10
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
11
|
-
builder.should_not be_nil
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "when using all defaults" do
|
15
|
-
|
16
|
-
before do
|
17
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
18
|
-
@expectation = builder.build
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should have the correct method_name" do
|
22
|
-
@expectation.method_name.should == :some_method
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should have empty args" do
|
26
|
-
@expectation.args.should be_empty
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should have no super call" do
|
30
|
-
@expectation.super.should == nil
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should have no error args" do
|
34
|
-
@expectation.error_args.should == nil
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should have no return_value" do
|
38
|
-
@expectation.return_value.should == nil
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should have no callback" do
|
42
|
-
@expectation.should_not be_has_callback
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "when specifying only arguments" do
|
48
|
-
|
49
|
-
before do
|
50
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
51
|
-
builder.with(1, 2, 3)
|
52
|
-
@expectation = builder.build
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should have the correct method_name" do
|
56
|
-
@expectation.method_name.should == :some_method
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should have empty args" do
|
60
|
-
@expectation.args.should == [1,2,3]
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should have no super call" do
|
64
|
-
@expectation.super.should == nil
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should have no error args" do
|
68
|
-
@expectation.error_args.should == nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it "should have no return_value" do
|
72
|
-
@expectation.return_value.should == nil
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should have no callback" do
|
76
|
-
@expectation.should_not be_has_callback
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "when specifying only a block for the return value" do
|
82
|
-
|
83
|
-
before do
|
84
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
85
|
-
builder.return { 5 }
|
86
|
-
@expectation = builder.build
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should have the correct method_name" do
|
90
|
-
@expectation.method_name.should == :some_method
|
91
|
-
end
|
92
|
-
|
93
|
-
it "should have empty args" do
|
94
|
-
@expectation.args.should be_empty
|
95
|
-
end
|
96
|
-
|
97
|
-
it "should have no super call" do
|
98
|
-
@expectation.super.should == nil
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should have no error args" do
|
102
|
-
@expectation.error_args.should == nil
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should have a return callback" do
|
106
|
-
@expectation.return_callback.should_not be_nil
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should have the correct return_value" do
|
110
|
-
@expectation.return_callback.call.should == 5
|
111
|
-
end
|
112
|
-
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "when specifying a return value" do
|
116
|
-
|
117
|
-
before do
|
118
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
119
|
-
builder.return 5
|
120
|
-
@expectation = builder.build
|
121
|
-
end
|
122
|
-
|
123
|
-
it "should have the correct method_name" do
|
124
|
-
@expectation.method_name.should == :some_method
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should have empty args" do
|
128
|
-
@expectation.args.should be_empty
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should have no super call" do
|
132
|
-
@expectation.super.should == nil
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should have no error args" do
|
136
|
-
@expectation.error_args.should == nil
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should have the correct return_value" do
|
140
|
-
@expectation.return_value.should == 5
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
145
|
-
describe "when specifying a raise arguments" do
|
146
|
-
|
147
|
-
before do
|
148
|
-
@msg = "Hold on, that wasn't supposed to happen"
|
149
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
150
|
-
builder.raise @msg
|
151
|
-
@expectation = builder.build
|
152
|
-
end
|
153
|
-
|
154
|
-
it "should have the correct method_name" do
|
155
|
-
@expectation.method_name.should == :some_method
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should have empty args" do
|
159
|
-
@expectation.args.should be_empty
|
160
|
-
end
|
161
|
-
|
162
|
-
it "should have no super call" do
|
163
|
-
@expectation.super.should == nil
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should have no error args" do
|
167
|
-
@expectation.error_args.should == [@msg]
|
168
|
-
end
|
169
|
-
|
170
|
-
it "should have the correct return_value" do
|
171
|
-
@expectation.return_value.should == nil
|
172
|
-
end
|
173
|
-
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "when specifying a return value and telling you want a call to super before" do
|
177
|
-
|
178
|
-
before do
|
179
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
180
|
-
builder.return(5).super_before
|
181
|
-
@expectation = builder.build
|
182
|
-
end
|
183
|
-
|
184
|
-
it "should have the correct method_name" do
|
185
|
-
@expectation.method_name.should == :some_method
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should have empty args" do
|
189
|
-
@expectation.args.should be_empty
|
190
|
-
end
|
191
|
-
|
192
|
-
it "should have no super call" do
|
193
|
-
@expectation.super.should == :before
|
194
|
-
end
|
195
|
-
|
196
|
-
it "should have no error args" do
|
197
|
-
@expectation.error_args.should == nil
|
198
|
-
end
|
199
|
-
|
200
|
-
it "should have the correct return_value" do
|
201
|
-
@expectation.return_value.should == 5
|
202
|
-
end
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
describe "when giving a block to the arguments constraint it should register it as a callback" do
|
207
|
-
|
208
|
-
before do
|
209
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
210
|
-
@counter, @args = 0, []
|
211
|
-
builder.with(5) do |*args|
|
212
|
-
@counter += 1
|
213
|
-
@args = args
|
214
|
-
end
|
215
|
-
@expectation = builder.build
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should have a callback" do
|
219
|
-
@expectation.should be_has_callback
|
220
|
-
end
|
221
|
-
|
222
|
-
it "should call the callback when the expectation is called" do
|
223
|
-
@expectation.execute
|
224
|
-
@counter.should == 1
|
225
|
-
end
|
226
|
-
|
227
|
-
it "should pass on the correct arguments" do
|
228
|
-
@expectation.execute 1, 2, 3
|
229
|
-
@args.should == [1, 2, 3]
|
230
|
-
end
|
231
|
-
end
|
232
|
-
|
233
|
-
describe "when giving a block to a super method it should register it" do
|
234
|
-
|
235
|
-
before do
|
236
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
237
|
-
@counter = 0
|
238
|
-
builder.super_after do
|
239
|
-
@counter += 1
|
240
|
-
end
|
241
|
-
@expectation = builder.build
|
242
|
-
end
|
243
|
-
|
244
|
-
it "should should have a callback" do
|
245
|
-
@expectation.block.should_not be_nil
|
246
|
-
end
|
247
|
-
|
248
|
-
it "should pass on the correct callback" do
|
249
|
-
@expectation.block.call
|
250
|
-
@counter.should == 1
|
251
|
-
end
|
252
|
-
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "when given arguments to the block pass method" do
|
256
|
-
|
257
|
-
before do
|
258
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
259
|
-
builder.pass_block(1,2,3)
|
260
|
-
@expectation = builder.build
|
261
|
-
end
|
262
|
-
|
263
|
-
it "should not have a block callback" do
|
264
|
-
@expectation.should_not be_has_block_callback
|
265
|
-
end
|
266
|
-
|
267
|
-
it "should should execute the block with the provided arguments when executed" do
|
268
|
-
ags = []
|
269
|
-
@expectation.execute do |*args|
|
270
|
-
ags = args
|
271
|
-
end
|
272
|
-
ags.should == [1,2,3]
|
273
|
-
end
|
274
|
-
|
275
|
-
end
|
276
|
-
|
277
|
-
describe "when given arguments to the block pass method" do
|
278
|
-
|
279
|
-
before do
|
280
|
-
builder = Caricature::ExpectationBuilder.new :some_method
|
281
|
-
builder.pass_block do
|
282
|
-
[1,3,4]
|
283
|
-
end
|
284
|
-
@expectation = builder.build
|
285
|
-
end
|
286
|
-
|
287
|
-
it "should have a block callback" do
|
288
|
-
@expectation.should be_has_block_callback
|
289
|
-
end
|
290
|
-
|
291
|
-
it "should execute the block with the result of the provided callback when executed" do
|
292
|
-
ags = []
|
293
|
-
@expectation.execute do |*args|
|
294
|
-
ags = args
|
295
|
-
end
|
296
|
-
ags.should == [1,3,4]
|
297
|
-
end
|
298
|
-
|
299
|
-
end
|
300
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "Caricature::Expectations" do
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Caricature::ExpectationBuilder" do
|
8
|
+
|
9
|
+
it "should create an expectation builder" do
|
10
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
11
|
+
builder.should_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "when using all defaults" do
|
15
|
+
|
16
|
+
before do
|
17
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
18
|
+
@expectation = builder.build
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have the correct method_name" do
|
22
|
+
@expectation.method_name.should == :some_method
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have empty args" do
|
26
|
+
@expectation.args.should be_empty
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have no super call" do
|
30
|
+
@expectation.super.should == nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have no error args" do
|
34
|
+
@expectation.error_args.should == nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have no return_value" do
|
38
|
+
@expectation.return_value.should == nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have no callback" do
|
42
|
+
@expectation.should_not be_has_callback
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "when specifying only arguments" do
|
48
|
+
|
49
|
+
before do
|
50
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
51
|
+
builder.with(1, 2, 3)
|
52
|
+
@expectation = builder.build
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have the correct method_name" do
|
56
|
+
@expectation.method_name.should == :some_method
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have empty args" do
|
60
|
+
@expectation.args.should == [1,2,3]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have no super call" do
|
64
|
+
@expectation.super.should == nil
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have no error args" do
|
68
|
+
@expectation.error_args.should == nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should have no return_value" do
|
72
|
+
@expectation.return_value.should == nil
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should have no callback" do
|
76
|
+
@expectation.should_not be_has_callback
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "when specifying only a block for the return value" do
|
82
|
+
|
83
|
+
before do
|
84
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
85
|
+
builder.return { 5 }
|
86
|
+
@expectation = builder.build
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should have the correct method_name" do
|
90
|
+
@expectation.method_name.should == :some_method
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should have empty args" do
|
94
|
+
@expectation.args.should be_empty
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should have no super call" do
|
98
|
+
@expectation.super.should == nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should have no error args" do
|
102
|
+
@expectation.error_args.should == nil
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should have a return callback" do
|
106
|
+
@expectation.return_callback.should_not be_nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should have the correct return_value" do
|
110
|
+
@expectation.return_callback.call.should == 5
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "when specifying a return value" do
|
116
|
+
|
117
|
+
before do
|
118
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
119
|
+
builder.return 5
|
120
|
+
@expectation = builder.build
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should have the correct method_name" do
|
124
|
+
@expectation.method_name.should == :some_method
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should have empty args" do
|
128
|
+
@expectation.args.should be_empty
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should have no super call" do
|
132
|
+
@expectation.super.should == nil
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should have no error args" do
|
136
|
+
@expectation.error_args.should == nil
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should have the correct return_value" do
|
140
|
+
@expectation.return_value.should == 5
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "when specifying a raise arguments" do
|
146
|
+
|
147
|
+
before do
|
148
|
+
@msg = "Hold on, that wasn't supposed to happen"
|
149
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
150
|
+
builder.raise @msg
|
151
|
+
@expectation = builder.build
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should have the correct method_name" do
|
155
|
+
@expectation.method_name.should == :some_method
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should have empty args" do
|
159
|
+
@expectation.args.should be_empty
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should have no super call" do
|
163
|
+
@expectation.super.should == nil
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should have no error args" do
|
167
|
+
@expectation.error_args.should == [@msg]
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should have the correct return_value" do
|
171
|
+
@expectation.return_value.should == nil
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "when specifying a return value and telling you want a call to super before" do
|
177
|
+
|
178
|
+
before do
|
179
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
180
|
+
builder.return(5).super_before
|
181
|
+
@expectation = builder.build
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should have the correct method_name" do
|
185
|
+
@expectation.method_name.should == :some_method
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should have empty args" do
|
189
|
+
@expectation.args.should be_empty
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should have no super call" do
|
193
|
+
@expectation.super.should == :before
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should have no error args" do
|
197
|
+
@expectation.error_args.should == nil
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should have the correct return_value" do
|
201
|
+
@expectation.return_value.should == 5
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
describe "when giving a block to the arguments constraint it should register it as a callback" do
|
207
|
+
|
208
|
+
before do
|
209
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
210
|
+
@counter, @args = 0, []
|
211
|
+
builder.with(5) do |*args|
|
212
|
+
@counter += 1
|
213
|
+
@args = args
|
214
|
+
end
|
215
|
+
@expectation = builder.build
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should have a callback" do
|
219
|
+
@expectation.should be_has_callback
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should call the callback when the expectation is called" do
|
223
|
+
@expectation.execute
|
224
|
+
@counter.should == 1
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should pass on the correct arguments" do
|
228
|
+
@expectation.execute 1, 2, 3
|
229
|
+
@args.should == [1, 2, 3]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "when giving a block to a super method it should register it" do
|
234
|
+
|
235
|
+
before do
|
236
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
237
|
+
@counter = 0
|
238
|
+
builder.super_after do
|
239
|
+
@counter += 1
|
240
|
+
end
|
241
|
+
@expectation = builder.build
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should should have a callback" do
|
245
|
+
@expectation.block.should_not be_nil
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should pass on the correct callback" do
|
249
|
+
@expectation.block.call
|
250
|
+
@counter.should == 1
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "when given arguments to the block pass method" do
|
256
|
+
|
257
|
+
before do
|
258
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
259
|
+
builder.pass_block(1,2,3)
|
260
|
+
@expectation = builder.build
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should not have a block callback" do
|
264
|
+
@expectation.should_not be_has_block_callback
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should should execute the block with the provided arguments when executed" do
|
268
|
+
ags = []
|
269
|
+
@expectation.execute do |*args|
|
270
|
+
ags = args
|
271
|
+
end
|
272
|
+
ags.should == [1,2,3]
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "when given arguments to the block pass method" do
|
278
|
+
|
279
|
+
before do
|
280
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
281
|
+
builder.pass_block do
|
282
|
+
[1,3,4]
|
283
|
+
end
|
284
|
+
@expectation = builder.build
|
285
|
+
end
|
286
|
+
|
287
|
+
it "should have a block callback" do
|
288
|
+
@expectation.should be_has_block_callback
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should execute the block with the result of the provided callback when executed" do
|
292
|
+
ags = []
|
293
|
+
@expectation.execute do |*args|
|
294
|
+
ags = args
|
295
|
+
end
|
296
|
+
ags.should == [1,3,4]
|
297
|
+
end
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
301
|
end
|
@@ -1,30 +1,30 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "Event handling" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe "for precompiled CLR classes" do
|
8
|
-
|
9
|
-
before do
|
10
|
-
@warrior = ClrModels::ExposingWarrior.new
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should subscribe to an event" do
|
14
|
-
ClrModels::ExposedChangedSubscriber.new(@warrior)
|
15
|
-
@warrior.has_event_subscriptions.should be_true
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should not raise an error when subcribing to an event" do
|
19
|
-
lambda { ClrModels::ExposedChangedSubscriber.new(@warrior) }.should_not raise_error
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should handle an event when raised" do
|
23
|
-
subscriber = ClrModels::ExposedChangedSubscriber.new(@warrior)
|
24
|
-
@warrior.change_is_exposed
|
25
|
-
subscriber.counter.should == 1
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "Event handling" do
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
describe "for precompiled CLR classes" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@warrior = ClrModels::ExposingWarrior.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should subscribe to an event" do
|
14
|
+
ClrModels::ExposedChangedSubscriber.new(@warrior)
|
15
|
+
@warrior.has_event_subscriptions.should be_true
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should not raise an error when subcribing to an event" do
|
19
|
+
lambda { ClrModels::ExposedChangedSubscriber.new(@warrior) }.should_not raise_error
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should handle an event when raised" do
|
23
|
+
subscriber = ClrModels::ExposedChangedSubscriber.new(@warrior)
|
24
|
+
@warrior.change_is_exposed
|
25
|
+
subscriber.counter.should == 1
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
30
|
end
|