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,157 +1,157 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "Callbacks on expectations" do
|
4
|
-
|
5
|
-
describe "CLR to CLR interactions" do
|
6
|
-
|
7
|
-
describe "when isolating CLR interfaces" do
|
8
|
-
|
9
|
-
before do
|
10
|
-
@ninja = ClrModels::Ninja.new
|
11
|
-
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should execute the callback when the expectation is invoked" do
|
15
|
-
ninja = ClrModels::Ninja.new
|
16
|
-
cnt = 0
|
17
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
18
|
-
cnt += 1
|
19
|
-
end
|
20
|
-
@ninja.attack ninja, @weapon
|
21
|
-
|
22
|
-
cnt.should == 1
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "when isolating CLR classes" do
|
28
|
-
|
29
|
-
before do
|
30
|
-
@ninja = ClrModels::Ninja.new
|
31
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should execute the callback when the expectation is invoked" do
|
35
|
-
ninja = ClrModels::Ninja.new
|
36
|
-
cnt = 0
|
37
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
38
|
-
cnt += 1
|
39
|
-
end
|
40
|
-
@ninja.attack ninja, @weapon
|
41
|
-
|
42
|
-
cnt.should == 1
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
|
47
|
-
describe "when isolating CLR instances" do
|
48
|
-
before do
|
49
|
-
@ninja = ClrModels::Ninja.new
|
50
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should execute the callback when the expectation is invoked" do
|
54
|
-
ninja = ClrModels::Ninja.new
|
55
|
-
cnt = 0
|
56
|
-
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
57
|
-
cnt += 1
|
58
|
-
end
|
59
|
-
@ninja.attack ninja, @weapon
|
60
|
-
|
61
|
-
cnt.should == 1
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "CLR to ruby interactions" do
|
68
|
-
|
69
|
-
describe "when isolating CLR interfaces" do
|
70
|
-
|
71
|
-
before do
|
72
|
-
@ninja = Soldier.new
|
73
|
-
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should execute the callback when the expectation is invoked" do
|
77
|
-
ninja = Soldier.new
|
78
|
-
cnt = 0
|
79
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
80
|
-
cnt += 1
|
81
|
-
end
|
82
|
-
@ninja.attack ninja, @weapon
|
83
|
-
|
84
|
-
cnt.should == 1
|
85
|
-
end
|
86
|
-
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "when isolating CLR classes" do
|
90
|
-
|
91
|
-
before do
|
92
|
-
@ninja = Soldier.new
|
93
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should execute the callback when the expectation is invoked" do
|
97
|
-
ninja = Soldier.new
|
98
|
-
cnt = 0
|
99
|
-
@weapon.when_receiving(:attack).with(:any) do |*args|
|
100
|
-
cnt += 1
|
101
|
-
end
|
102
|
-
@ninja.attack ninja, @weapon
|
103
|
-
|
104
|
-
cnt.should == 1
|
105
|
-
end
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "when isolating CLR instances" do
|
110
|
-
before do
|
111
|
-
@ninja = Soldier.new
|
112
|
-
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should execute the callback when the expectation is invoked" do
|
116
|
-
ninja = Soldier.new
|
117
|
-
cnt = 0
|
118
|
-
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
119
|
-
cnt += 1
|
120
|
-
end
|
121
|
-
@ninja.attack ninja, @weapon
|
122
|
-
|
123
|
-
cnt.should == 1
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
|
128
|
-
end
|
129
|
-
|
130
|
-
describe "Ruby to Ruby interactions" do
|
131
|
-
|
132
|
-
it "should execute a callback when an expectation is being invoked and with is not defined in a block" do
|
133
|
-
iso = Caricature::Isolation.for(Dagger)
|
134
|
-
cnt = 0
|
135
|
-
iso.when_receiving(:damage).with(:any) do |*args|
|
136
|
-
cnt += 1
|
137
|
-
end
|
138
|
-
iso.damage
|
139
|
-
cnt.should == 1
|
140
|
-
end
|
141
|
-
|
142
|
-
it "should execute a callback when an expectation is being invoked and with is defined in a block" do
|
143
|
-
cnt = 0
|
144
|
-
iso = Caricature::Isolation.for(Dagger)
|
145
|
-
iso.when_receiving(:damage) do |exp|
|
146
|
-
exp.with(:any) do |*args|
|
147
|
-
cnt += 1
|
148
|
-
end
|
149
|
-
end
|
150
|
-
iso.damage
|
151
|
-
cnt.should == 1
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
|
156
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "Callbacks on expectations" do
|
4
|
+
|
5
|
+
describe "CLR to CLR interactions" do
|
6
|
+
|
7
|
+
describe "when isolating CLR interfaces" do
|
8
|
+
|
9
|
+
before do
|
10
|
+
@ninja = ClrModels::Ninja.new
|
11
|
+
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should execute the callback when the expectation is invoked" do
|
15
|
+
ninja = ClrModels::Ninja.new
|
16
|
+
cnt = 0
|
17
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
18
|
+
cnt += 1
|
19
|
+
end
|
20
|
+
@ninja.attack ninja, @weapon
|
21
|
+
|
22
|
+
cnt.should == 1
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "when isolating CLR classes" do
|
28
|
+
|
29
|
+
before do
|
30
|
+
@ninja = ClrModels::Ninja.new
|
31
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should execute the callback when the expectation is invoked" do
|
35
|
+
ninja = ClrModels::Ninja.new
|
36
|
+
cnt = 0
|
37
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
38
|
+
cnt += 1
|
39
|
+
end
|
40
|
+
@ninja.attack ninja, @weapon
|
41
|
+
|
42
|
+
cnt.should == 1
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "when isolating CLR instances" do
|
48
|
+
before do
|
49
|
+
@ninja = ClrModels::Ninja.new
|
50
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should execute the callback when the expectation is invoked" do
|
54
|
+
ninja = ClrModels::Ninja.new
|
55
|
+
cnt = 0
|
56
|
+
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
57
|
+
cnt += 1
|
58
|
+
end
|
59
|
+
@ninja.attack ninja, @weapon
|
60
|
+
|
61
|
+
cnt.should == 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "CLR to ruby interactions" do
|
68
|
+
|
69
|
+
describe "when isolating CLR interfaces" do
|
70
|
+
|
71
|
+
before do
|
72
|
+
@ninja = Soldier.new
|
73
|
+
@weapon = Caricature::Isolation.for(ClrModels::IWeapon)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should execute the callback when the expectation is invoked" do
|
77
|
+
ninja = Soldier.new
|
78
|
+
cnt = 0
|
79
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
80
|
+
cnt += 1
|
81
|
+
end
|
82
|
+
@ninja.attack ninja, @weapon
|
83
|
+
|
84
|
+
cnt.should == 1
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "when isolating CLR classes" do
|
90
|
+
|
91
|
+
before do
|
92
|
+
@ninja = Soldier.new
|
93
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword)
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should execute the callback when the expectation is invoked" do
|
97
|
+
ninja = Soldier.new
|
98
|
+
cnt = 0
|
99
|
+
@weapon.when_receiving(:attack).with(:any) do |*args|
|
100
|
+
cnt += 1
|
101
|
+
end
|
102
|
+
@ninja.attack ninja, @weapon
|
103
|
+
|
104
|
+
cnt.should == 1
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "when isolating CLR instances" do
|
110
|
+
before do
|
111
|
+
@ninja = Soldier.new
|
112
|
+
@weapon = Caricature::Isolation.for(ClrModels::Sword.new)
|
113
|
+
end
|
114
|
+
|
115
|
+
it "should execute the callback when the expectation is invoked" do
|
116
|
+
ninja = Soldier.new
|
117
|
+
cnt = 0
|
118
|
+
@weapon.when_receiving(:attack).with(ninja) do |*args|
|
119
|
+
cnt += 1
|
120
|
+
end
|
121
|
+
@ninja.attack ninja, @weapon
|
122
|
+
|
123
|
+
cnt.should == 1
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "Ruby to Ruby interactions" do
|
131
|
+
|
132
|
+
it "should execute a callback when an expectation is being invoked and with is not defined in a block" do
|
133
|
+
iso = Caricature::Isolation.for(Dagger)
|
134
|
+
cnt = 0
|
135
|
+
iso.when_receiving(:damage).with(:any) do |*args|
|
136
|
+
cnt += 1
|
137
|
+
end
|
138
|
+
iso.damage
|
139
|
+
cnt.should == 1
|
140
|
+
end
|
141
|
+
|
142
|
+
it "should execute a callback when an expectation is being invoked and with is defined in a block" do
|
143
|
+
cnt = 0
|
144
|
+
iso = Caricature::Isolation.for(Dagger)
|
145
|
+
iso.when_receiving(:damage) do |exp|
|
146
|
+
exp.with(:any) do |*args|
|
147
|
+
cnt += 1
|
148
|
+
end
|
149
|
+
end
|
150
|
+
iso.damage
|
151
|
+
cnt.should == 1
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
|
156
|
+
|
157
157
|
end
|