caricature 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/README.rdoc +97 -97
  2. data/Rakefile +309 -310
  3. data/caricature.gemspec +123 -110
  4. data/lib/caricature/bacon/integration.rb +75 -75
  5. data/lib/caricature/bacon.rb +2 -2
  6. data/lib/caricature/clr/descriptor.rb +159 -159
  7. data/lib/caricature/clr/event_verification.rb +56 -56
  8. data/lib/caricature/clr/expectation.rb +100 -100
  9. data/lib/caricature/clr/isolation.rb +78 -78
  10. data/lib/caricature/clr/isolator.rb +252 -252
  11. data/lib/caricature/clr/messenger.rb +51 -49
  12. data/lib/caricature/clr/method_call_recorder.rb +96 -96
  13. data/lib/caricature/expectation.rb +1 -1
  14. data/lib/caricature/method_call_recorder.rb +3 -3
  15. data/lib/caricature/rspec/integration.rb +118 -118
  16. data/lib/caricature/version.rb +5 -5
  17. data/lib/caricature.rb +25 -25
  18. data/spec/bacon/integration/callback_spec.rb +156 -156
  19. data/spec/bacon/integration/clr_to_clr_spec.rb +325 -253
  20. data/spec/bacon/integration/event_spec.rb +97 -97
  21. data/spec/bacon/integration/indexer_spec.rb +27 -27
  22. data/spec/bacon/spec_helper.rb +4 -4
  23. data/spec/bacon/unit/descriptor_spec.rb +212 -212
  24. data/spec/bacon/unit/sword_spec.rb +39 -39
  25. data/spec/bacon/unit/verification_spec.rb +103 -103
  26. data/spec/bin/ClrModels.dll +0 -0
  27. data/spec/bin/ClrModels.dll.mdb +0 -0
  28. data/spec/fixtures/ExplodingCar.cs +56 -0
  29. data/spec/fixtures/ExposedChangedSubscriber.cs +26 -0
  30. data/spec/fixtures/ExposingWarrior.cs +58 -0
  31. data/spec/fixtures/IExplodingWarrior.cs +10 -0
  32. data/spec/fixtures/IExposing.cs +9 -0
  33. data/spec/fixtures/IExposingBridge.cs +9 -0
  34. data/spec/fixtures/IExposingWarrior.cs +8 -0
  35. data/spec/fixtures/IHaveAnIndexer.cs +8 -0
  36. data/spec/fixtures/IWarrior.cs +13 -0
  37. data/spec/fixtures/IWeapon.cs +9 -0
  38. data/spec/fixtures/IndexerCaller.cs +17 -0
  39. data/spec/fixtures/IndexerContained.cs +20 -0
  40. data/spec/fixtures/MyClassWithAStatic.cs +16 -0
  41. data/spec/fixtures/Ninja.cs +34 -0
  42. data/spec/fixtures/Samurai.cs +29 -0
  43. data/spec/fixtures/StaticCaller.cs +12 -0
  44. data/spec/fixtures/Sword.cs +16 -0
  45. data/spec/fixtures/SwordWithStatics.cs +19 -0
  46. data/spec/fixtures/clr_interaction.rb +61 -0
  47. data/spec/fixtures/dagger.rb +11 -0
  48. data/spec/fixtures/dagger_with_class_members.rb +11 -0
  49. data/spec/fixtures/sheath.rb +19 -0
  50. data/spec/fixtures/soldier.rb +29 -0
  51. data/spec/fixtures/soldier_with_class_members.rb +7 -0
  52. data/spec/fixtures/swift_cleanup_crew.rb +21 -0
  53. data/spec/fixtures/with_class_methods.rb +11 -0
  54. data/spec/{models → models.notused}/ClrModels.cs +241 -241
  55. data/spec/{models → models.notused}/ruby_models.rb +150 -150
  56. data/spec/rspec/integration/callback_spec.rb +156 -156
  57. data/spec/rspec/integration/clr_to_clr_spec.rb +254 -254
  58. data/spec/rspec/integration/clr_to_ruby_spec.rb +227 -227
  59. data/spec/rspec/integration/indexer_spec.rb +27 -27
  60. data/spec/rspec/integration/ruby_to_ruby_spec.rb +271 -271
  61. data/spec/rspec/spec_helper.rb +12 -12
  62. data/spec/rspec/unit/core_ext_spec.rb +87 -87
  63. data/spec/rspec/unit/descriptor_spec.rb +210 -210
  64. data/spec/rspec/unit/event_spec.rb +16 -16
  65. data/spec/rspec/unit/expectation_spec.rb +300 -300
  66. data/spec/rspec/unit/interop_spec.rb +29 -29
  67. data/spec/rspec/unit/isolation_spec.rb +86 -86
  68. data/spec/rspec/unit/isolator_spec.rb +219 -219
  69. data/spec/rspec/unit/messaging_spec.rb +310 -310
  70. data/spec/rspec/unit/method_call_spec.rb +342 -342
  71. data/spec/rspec/unit/sword_spec.rb +39 -39
  72. data/spec/rspec/unit/verification_spec.rb +103 -103
  73. data/spec/spec_helper.rb +16 -15
  74. metadata +42 -11
@@ -1,228 +1,228 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- describe "CLR isolations for ruby objects" do
4
-
5
- describe "when isolating CLR interfaces" do
6
- before do
7
- @soldier = Soldier.new
8
- @weapon = Caricature::Isolation.for(ClrModels::IWeapon)
9
- end
10
-
11
- it "should work without expectations" do
12
- @soldier.attack Soldier.new, @weapon
13
-
14
- @weapon.did_receive?(:attack).should be_successful
15
- end
16
-
17
- it "should work for expectations with an argument constraint" do
18
- soldier = Soldier.new
19
- @weapon.when_receiving(:attack).with(soldier).return(5)
20
-
21
- @soldier.attack(soldier, @weapon).should == 5
22
-
23
- @weapon.did_receive?(:attack).with(:any).should be_successful
24
- end
25
-
26
- it "should work for expectations with an argument constraint when a wrong argument is passed in" do
27
- @weapon.when_receiving(:attack).with(Soldier.new).return(5)
28
-
29
- @soldier.attack(Soldier.new, @weapon).should == 0
30
- end
31
-
32
- it "should work for expectations with an argument constraint and an assertion argument constraint" do
33
- soldier = Soldier.new
34
- @weapon.when_receiving(:attack).with(soldier).return(5)
35
-
36
- @soldier.attack(soldier, @weapon).should == 5
37
-
38
- @weapon.did_receive?(:attack).with(soldier).should be_successful
39
- end
40
-
41
- it "should fail for expectations with an argument constraint and an assertion argument constraint" do
42
- soldier = Soldier.new
43
- @weapon.when_receiving(:attack).with(soldier).return(5)
44
-
45
- @soldier.attack(soldier, @weapon).should == 5
46
-
47
- @weapon.did_receive?(:attack).with(Soldier.new).should_not be_successful
48
- end
49
-
50
- it "should work with an expectation with any arguments" do
51
- @weapon.when_receiving(:damage).return(5)
52
-
53
- @soldier.is_killed_by?(@weapon).should be_true
54
- @weapon.did_receive?(:damage).should be_successful
55
- end
56
-
57
- it "should work with an expectation getting different method call result" do
58
- @weapon.when_receiving(:damage).return(2)
59
-
60
- @soldier.is_killed_by?(@weapon).should be_false
61
- @weapon.did_receive?(:damage).should be_successful
62
- end
63
-
64
- it "should work for an assertion on a specific argument" do
65
- @weapon.when_receiving(:damage).return(2)
66
-
67
- @soldier.is_killed_by?(@weapon).should be_false
68
- @weapon.did_receive?(:damage).should be_successful
69
- end
70
-
71
- end
72
-
73
- describe "when isolating CLR classes" do
74
-
75
- before do
76
- @weapon = Dagger.new
77
- @ninja = Caricature::Isolation.for(ClrModels::Ninja)
78
- end
79
-
80
- it "should work without expectations" do
81
- result = @weapon.attack @ninja
82
- result.should == 0
83
-
84
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
85
- end
86
-
87
- it "should work for expectations with an argument constraint" do
88
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
89
-
90
- @weapon.attack(@ninja).should == 5
91
-
92
- @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
93
- end
94
-
95
- it "should work for expectations with an argument constraint when a wrong argument is passed in" do
96
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
97
-
98
- @weapon.attack(Soldier.new).should == 8
99
-
100
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should_not be_successful
101
- end
102
-
103
- it "should work for expectations with an argument constraint and an assertion argument constraint" do
104
- ninja = ClrModels::Ninja.new
105
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
106
-
107
- @weapon.attack(@ninja).should == 5
108
-
109
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
110
- end
111
-
112
- it "should fail for expectations with an argument constraint and an assertion argument constraint" do
113
- ninja = ClrModels::Ninja.new
114
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
115
-
116
- @weapon.attack(@ninja).should == 5
117
-
118
- @ninja.did_receive?(:survive_attack_with).with(Dagger.new).should_not be_successful
119
- end
120
-
121
- it "should work with an expectation for any arguments" do
122
- @ninja.when_receiving(:survive_attack_with).return(5)
123
-
124
- result = @weapon.attack @ninja
125
- result.should == 5
126
-
127
- @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
128
- end
129
-
130
- it "should work with an assertion for specific arguments" do
131
- @ninja.when_receiving(:survive_attack_with) do |method_should|
132
- method_should.return(5)
133
- end
134
-
135
- result = @weapon.attack @ninja
136
- result.should == 5
137
-
138
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
139
- end
140
-
141
- it "should fail for an assertion with wrong arguments" do
142
- @ninja.when_receiving(:survive_attack_with) do |method_should|
143
- method_should.return(5)
144
- end
145
-
146
- result = @weapon.attack @ninja
147
- result.should == 5
148
-
149
- @ninja.
150
- did_receive?(:survive_attack_with).
151
- with(Caricature::Isolation.for(ClrModels::IWeapon)).
152
- should_not be_successful
153
- end
154
-
155
- end
156
-
157
- describe "when isolating CLR instances" do
158
-
159
- before do
160
- @weapon = Dagger.new
161
- @ninja = Caricature::Isolation.for(ClrModels::Ninja.new)
162
- end
163
-
164
- it "should work without expectations" do
165
- result = @weapon.attack @ninja
166
- result.should == 0
167
-
168
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
169
- end
170
-
171
- it "should work for expectations with an argument constraint" do
172
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
173
-
174
- @weapon.attack(@ninja).should == 5
175
-
176
- @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
177
- end
178
-
179
- it "should work for expectations with an argument constraint when a wrong argument is passed in" do
180
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
181
-
182
- @weapon.attack(Soldier.new).should == 8
183
-
184
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should_not be_successful
185
- end
186
-
187
- it "should work for expectations with an argument constraint and an assertion argument constraint" do
188
- ninja = ClrModels::Ninja.new
189
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
190
-
191
- @weapon.attack(@ninja).should == 5
192
-
193
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
194
- end
195
-
196
- it "should fail for expectations with an argument constraint and an assertion argument constraint" do
197
- ninja = ClrModels::Ninja.new
198
- @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
199
-
200
- @weapon.attack(@ninja).should == 5
201
-
202
- @ninja.did_receive?(:survive_attack_with).with(Dagger.new).should_not be_successful
203
- end
204
-
205
- it "should work with an expectation for any arguments" do
206
- @ninja.when_receiving(:survive_attack_with).return(5)
207
-
208
- result = @weapon.attack @ninja
209
- result.should == 5
210
-
211
- @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
212
- end
213
-
214
- it "should fail for an assertion for specific arguments" do
215
- @ninja.when_receiving(:survive_attack_with) do |method_should|
216
- method_should.return(5)
217
- end
218
-
219
- result = @weapon.attack @ninja
220
- result.should == 5
221
- var = @ninja.did_receive?(:survive_attack_with).with(:any)
222
- @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
223
- end
224
-
225
-
226
- end
227
-
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe "CLR isolations for ruby objects" do
4
+
5
+ describe "when isolating CLR interfaces" do
6
+ before do
7
+ @soldier = Soldier.new
8
+ @weapon = Caricature::Isolation.for(ClrModels::IWeapon)
9
+ end
10
+
11
+ it "should work without expectations" do
12
+ @soldier.attack Soldier.new, @weapon
13
+
14
+ @weapon.did_receive?(:attack).should be_successful
15
+ end
16
+
17
+ it "should work for expectations with an argument constraint" do
18
+ soldier = Soldier.new
19
+ @weapon.when_receiving(:attack).with(soldier).return(5)
20
+
21
+ @soldier.attack(soldier, @weapon).should == 5
22
+
23
+ @weapon.did_receive?(:attack).with(:any).should be_successful
24
+ end
25
+
26
+ it "should work for expectations with an argument constraint when a wrong argument is passed in" do
27
+ @weapon.when_receiving(:attack).with(Soldier.new).return(5)
28
+
29
+ @soldier.attack(Soldier.new, @weapon).should == 0
30
+ end
31
+
32
+ it "should work for expectations with an argument constraint and an assertion argument constraint" do
33
+ soldier = Soldier.new
34
+ @weapon.when_receiving(:attack).with(soldier).return(5)
35
+
36
+ @soldier.attack(soldier, @weapon).should == 5
37
+
38
+ @weapon.did_receive?(:attack).with(soldier).should be_successful
39
+ end
40
+
41
+ it "should fail for expectations with an argument constraint and an assertion argument constraint" do
42
+ soldier = Soldier.new
43
+ @weapon.when_receiving(:attack).with(soldier).return(5)
44
+
45
+ @soldier.attack(soldier, @weapon).should == 5
46
+
47
+ @weapon.did_receive?(:attack).with(Soldier.new).should_not be_successful
48
+ end
49
+
50
+ it "should work with an expectation with any arguments" do
51
+ @weapon.when_receiving(:damage).return(5)
52
+
53
+ @soldier.is_killed_by?(@weapon).should be_true
54
+ @weapon.did_receive?(:damage).should be_successful
55
+ end
56
+
57
+ it "should work with an expectation getting different method call result" do
58
+ @weapon.when_receiving(:damage).return(2)
59
+
60
+ @soldier.is_killed_by?(@weapon).should be_false
61
+ @weapon.did_receive?(:damage).should be_successful
62
+ end
63
+
64
+ it "should work for an assertion on a specific argument" do
65
+ @weapon.when_receiving(:damage).return(2)
66
+
67
+ @soldier.is_killed_by?(@weapon).should be_false
68
+ @weapon.did_receive?(:damage).should be_successful
69
+ end
70
+
71
+ end
72
+
73
+ describe "when isolating CLR classes" do
74
+
75
+ before do
76
+ @weapon = Dagger.new
77
+ @ninja = Caricature::Isolation.for(ClrModels::Ninja)
78
+ end
79
+
80
+ it "should work without expectations" do
81
+ result = @weapon.attack @ninja
82
+ result.should == 0
83
+
84
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
85
+ end
86
+
87
+ it "should work for expectations with an argument constraint" do
88
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
89
+
90
+ @weapon.attack(@ninja).should == 5
91
+
92
+ @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
93
+ end
94
+
95
+ it "should work for expectations with an argument constraint when a wrong argument is passed in" do
96
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
97
+
98
+ @weapon.attack(Soldier.new).should == 8
99
+
100
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should_not be_successful
101
+ end
102
+
103
+ it "should work for expectations with an argument constraint and an assertion argument constraint" do
104
+ ninja = ClrModels::Ninja.new
105
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
106
+
107
+ @weapon.attack(@ninja).should == 5
108
+
109
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
110
+ end
111
+
112
+ it "should fail for expectations with an argument constraint and an assertion argument constraint" do
113
+ ninja = ClrModels::Ninja.new
114
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
115
+
116
+ @weapon.attack(@ninja).should == 5
117
+
118
+ @ninja.did_receive?(:survive_attack_with).with(Dagger.new).should_not be_successful
119
+ end
120
+
121
+ it "should work with an expectation for any arguments" do
122
+ @ninja.when_receiving(:survive_attack_with).return(5)
123
+
124
+ result = @weapon.attack @ninja
125
+ result.should == 5
126
+
127
+ @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
128
+ end
129
+
130
+ it "should work with an assertion for specific arguments" do
131
+ @ninja.when_receiving(:survive_attack_with) do |method_should|
132
+ method_should.return(5)
133
+ end
134
+
135
+ result = @weapon.attack @ninja
136
+ result.should == 5
137
+
138
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
139
+ end
140
+
141
+ it "should fail for an assertion with wrong arguments" do
142
+ @ninja.when_receiving(:survive_attack_with) do |method_should|
143
+ method_should.return(5)
144
+ end
145
+
146
+ result = @weapon.attack @ninja
147
+ result.should == 5
148
+
149
+ @ninja.
150
+ did_receive?(:survive_attack_with).
151
+ with(Caricature::Isolation.for(ClrModels::IWeapon)).
152
+ should_not be_successful
153
+ end
154
+
155
+ end
156
+
157
+ describe "when isolating CLR instances" do
158
+
159
+ before do
160
+ @weapon = Dagger.new
161
+ @ninja = Caricature::Isolation.for(ClrModels::Ninja.new)
162
+ end
163
+
164
+ it "should work without expectations" do
165
+ result = @weapon.attack @ninja
166
+ result.should == 0
167
+
168
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
169
+ end
170
+
171
+ it "should work for expectations with an argument constraint" do
172
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
173
+
174
+ @weapon.attack(@ninja).should == 5
175
+
176
+ @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
177
+ end
178
+
179
+ it "should work for expectations with an argument constraint when a wrong argument is passed in" do
180
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
181
+
182
+ @weapon.attack(Soldier.new).should == 8
183
+
184
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should_not be_successful
185
+ end
186
+
187
+ it "should work for expectations with an argument constraint and an assertion argument constraint" do
188
+ ninja = ClrModels::Ninja.new
189
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
190
+
191
+ @weapon.attack(@ninja).should == 5
192
+
193
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
194
+ end
195
+
196
+ it "should fail for expectations with an argument constraint and an assertion argument constraint" do
197
+ ninja = ClrModels::Ninja.new
198
+ @ninja.when_receiving(:survive_attack_with).with(@weapon).return(5)
199
+
200
+ @weapon.attack(@ninja).should == 5
201
+
202
+ @ninja.did_receive?(:survive_attack_with).with(Dagger.new).should_not be_successful
203
+ end
204
+
205
+ it "should work with an expectation for any arguments" do
206
+ @ninja.when_receiving(:survive_attack_with).return(5)
207
+
208
+ result = @weapon.attack @ninja
209
+ result.should == 5
210
+
211
+ @ninja.did_receive?(:survive_attack_with).with(:any).should be_successful
212
+ end
213
+
214
+ it "should fail for an assertion for specific arguments" do
215
+ @ninja.when_receiving(:survive_attack_with) do |method_should|
216
+ method_should.return(5)
217
+ end
218
+
219
+ result = @weapon.attack @ninja
220
+ result.should == 5
221
+ var = @ninja.did_receive?(:survive_attack_with).with(:any)
222
+ @ninja.did_receive?(:survive_attack_with).with(@weapon).should be_successful
223
+ end
224
+
225
+
226
+ end
227
+
228
228
  end
@@ -1,28 +1,28 @@
1
- require File.dirname(__FILE__) + "/../spec_helper"
2
-
3
- describe "CLR to CLR interactions" do
4
-
5
- describe "when isolating CLR classes" do
6
-
7
- describe "that have an indexer" do
8
- before do
9
- @cons = ClrModels::IndexerCaller.new
10
- @ind = Caricature::Isolation.for(ClrModels::IndexerContained)
11
- end
12
-
13
- it "should work without expectations" do
14
- @cons.call_index_on_class(@ind, "key1").should be_nil
15
- end
16
-
17
- it "should work with an expectation" do
18
- @ind.when_receiving(:Item).return("5")
19
-
20
- @cons.call_index_on_class(@ind, "key1").should == "5"
21
- end
22
-
23
-
24
- end
25
-
26
- end
27
-
1
+ require File.dirname(__FILE__) + "/../spec_helper"
2
+
3
+ describe "CLR to CLR interactions" do
4
+
5
+ describe "when isolating CLR classes" do
6
+
7
+ describe "that have an indexer" do
8
+ before do
9
+ @cons = ClrModels::IndexerCaller.new
10
+ @ind = Caricature::Isolation.for(ClrModels::IndexerContained)
11
+ end
12
+
13
+ it "should work without expectations" do
14
+ @cons.call_index_on_class(@ind, "key1").should be_nil
15
+ end
16
+
17
+ it "should work with an expectation" do
18
+ @ind.when_receiving(:Item).return("5")
19
+
20
+ @cons.call_index_on_class(@ind, "key1").should == "5"
21
+ end
22
+
23
+
24
+ end
25
+
26
+ end
27
+
28
28
  end