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,87 +1,87 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "String" do
|
4
|
-
|
5
|
-
it "should underscore a camel cased name" do
|
6
|
-
"MockingAndStubbingForIronRuby1".underscore.should == "mocking_and_stubbing_for_iron_ruby1"
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should get the class if it exists" do
|
10
|
-
"String".classify.should == String
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "Module" do
|
16
|
-
|
17
|
-
it "should strip the module names" do
|
18
|
-
ClrModels::IExposingWarrior.demodulize.should == "IExposingWarrior"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should identify it's not a CLR type for a Ruby defined module" do
|
22
|
-
Caricature.should_not be_clr_type
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should identify it's a CLR type for a CLR defined interface" do
|
26
|
-
ClrModels::IExposingWarrior.should be_clr_type
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should identify it's a CLR type for a Ruby defined module that includes a CLR interface" do
|
30
|
-
Caricature::InterfaceIncludingModule.should be_clr_type
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should identify it's not a CLR type for a Ruby defined module that includes a Ruby module" do
|
34
|
-
Caricature::RubyModuleIncludingModule.should_not be_clr_type
|
35
|
-
end
|
36
|
-
|
37
|
-
it "should identify it's a CLR type when an ancestor includes a CLR interface" do
|
38
|
-
Caricature::InterfaceUpTheWazoo.should be_clr_type
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "Class" do
|
44
|
-
|
45
|
-
it "should strip the module names" do
|
46
|
-
ClrModels::Ninja.demodulize.should == "Ninja"
|
47
|
-
end
|
48
|
-
|
49
|
-
it "should identify it's not a CLR type for a ruby defined type" do
|
50
|
-
Soldier.should_not be_clr_type
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should identify it's not a CLR type for a ruby defined type that subclasses a Ruby class" do
|
54
|
-
Caricature::SubclassingRubyClass.should_not be_clr_type
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should identify it's not a CLR type for a ruby defined type that includes only ruby modueles in its hierarchy" do
|
58
|
-
Caricature::ModuleIncludingClass.should_not be_clr_type
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should identify it's a CLR type for a type defined in C#" do
|
62
|
-
ClrModels::Ninja.should be_clr_type
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should identify it's a CLR type for a type defined in Ruby that includes a CLR interface" do
|
66
|
-
Caricature::InterfaceIncludingClass.should be_clr_type
|
67
|
-
end
|
68
|
-
|
69
|
-
it "should identify it's a CLR type for a type defined in Ruby that subclasses a CLR class" do
|
70
|
-
Caricature::SubClassingClrClass.should be_clr_type
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should identify it's a CLR type for a type defined in Ruby that includes a CLR interface in its hierarchy" do
|
74
|
-
Caricature::InterfaceUpTheWazooClass.should be_clr_type
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "Array" do
|
80
|
-
|
81
|
-
it "should convert an array to a hash" do
|
82
|
-
expected = { :key1 => "value1", :key2 => "value2"}
|
83
|
-
%w(key1 value1 key2 value2).to_h.should == expected
|
84
|
-
end
|
85
|
-
|
86
|
-
end
|
87
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "String" do
|
4
|
+
|
5
|
+
it "should underscore a camel cased name" do
|
6
|
+
"MockingAndStubbingForIronRuby1".underscore.should == "mocking_and_stubbing_for_iron_ruby1"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should get the class if it exists" do
|
10
|
+
"String".classify.should == String
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "Module" do
|
16
|
+
|
17
|
+
it "should strip the module names" do
|
18
|
+
ClrModels::IExposingWarrior.demodulize.should == "IExposingWarrior"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should identify it's not a CLR type for a Ruby defined module" do
|
22
|
+
Caricature.should_not be_clr_type
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should identify it's a CLR type for a CLR defined interface" do
|
26
|
+
ClrModels::IExposingWarrior.should be_clr_type
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should identify it's a CLR type for a Ruby defined module that includes a CLR interface" do
|
30
|
+
Caricature::InterfaceIncludingModule.should be_clr_type
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should identify it's not a CLR type for a Ruby defined module that includes a Ruby module" do
|
34
|
+
Caricature::RubyModuleIncludingModule.should_not be_clr_type
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should identify it's a CLR type when an ancestor includes a CLR interface" do
|
38
|
+
Caricature::InterfaceUpTheWazoo.should be_clr_type
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "Class" do
|
44
|
+
|
45
|
+
it "should strip the module names" do
|
46
|
+
ClrModels::Ninja.demodulize.should == "Ninja"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should identify it's not a CLR type for a ruby defined type" do
|
50
|
+
Soldier.should_not be_clr_type
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should identify it's not a CLR type for a ruby defined type that subclasses a Ruby class" do
|
54
|
+
Caricature::SubclassingRubyClass.should_not be_clr_type
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should identify it's not a CLR type for a ruby defined type that includes only ruby modueles in its hierarchy" do
|
58
|
+
Caricature::ModuleIncludingClass.should_not be_clr_type
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should identify it's a CLR type for a type defined in C#" do
|
62
|
+
ClrModels::Ninja.should be_clr_type
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should identify it's a CLR type for a type defined in Ruby that includes a CLR interface" do
|
66
|
+
Caricature::InterfaceIncludingClass.should be_clr_type
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should identify it's a CLR type for a type defined in Ruby that subclasses a CLR class" do
|
70
|
+
Caricature::SubClassingClrClass.should be_clr_type
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should identify it's a CLR type for a type defined in Ruby that includes a CLR interface in its hierarchy" do
|
74
|
+
Caricature::InterfaceUpTheWazooClass.should be_clr_type
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "Array" do
|
80
|
+
|
81
|
+
it "should convert an array to a hash" do
|
82
|
+
expected = { :key1 => "value1", :key2 => "value2"}
|
83
|
+
%w(key1 value1 key2 value2).to_h.should == expected
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
@@ -1,211 +1,211 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "Caricature::TypeDescriptor" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@des = Caricature::TypeDescriptor.new :in_unit_test_for_class
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should have a class_members method" do
|
10
|
-
@des.should respond_to(:class_members)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should return an empty collection for the class members" do
|
14
|
-
@des.class_members.should be_empty
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should have an instance members method" do
|
18
|
-
@des.should respond_to(:instance_members)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should return an empty collection for the instance members" do
|
22
|
-
@des.instance_members.should be_empty
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should raise a NotImplementedError for the initialize_instance_members method" do
|
26
|
-
lambda { @des.initialize_instance_members_for Soldier }.should raise_error(NotImplementedError)
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should raise a NotImplementedError for the initialize_class_members method" do
|
30
|
-
lambda { @des.initialize_class_members_for Soldier }.should raise_error(NotImplementedError)
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "Caricature::MemberDescriptor" do
|
36
|
-
|
37
|
-
it "should have a name" do
|
38
|
-
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
39
|
-
des.name.should_not be_nil
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should have the correct name" do
|
43
|
-
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
44
|
-
des.name.should == 'a name'
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should have a return_type" do
|
48
|
-
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
49
|
-
des.return_type.should_not be_nil
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should have the correct return_type" do
|
53
|
-
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
54
|
-
des.return_type.should == 'a type'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should say it's an instance type" do
|
58
|
-
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
59
|
-
des.should be_instance_member
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should say it's not an instance type" do
|
63
|
-
des = Caricature::MemberDescriptor.new 'a name', 'a type', false
|
64
|
-
des.should_not be_instance_member
|
65
|
-
end
|
66
|
-
|
67
|
-
end
|
68
|
-
|
69
|
-
describe Caricature::ClrEventDescriptor do
|
70
|
-
|
71
|
-
it "should have an event name" do
|
72
|
-
des = Caricature::ClrEventDescriptor.new "EventName"
|
73
|
-
des.event_name.should == "EventName"
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should correctly identify when it's not an instance member" do
|
77
|
-
des = Caricature::ClrEventDescriptor.new "EventName", false
|
78
|
-
des.should_not be_instance_member
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
|
83
|
-
describe Caricature::ClrInterfaceDescriptor do
|
84
|
-
|
85
|
-
context "when collecting methods" do
|
86
|
-
before do
|
87
|
-
@des = Caricature::ClrInterfaceDescriptor.new ClrModels::IWeapon
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should have 2 instance members" do
|
91
|
-
@des.instance_members.size.should == 2
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should contain only instance members" do
|
95
|
-
result = true
|
96
|
-
@des.instance_members.each do |mem|
|
97
|
-
result = false unless mem.instance_member?
|
98
|
-
end
|
99
|
-
|
100
|
-
result.should be_true
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should have a damage instance member" do
|
104
|
-
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should correctly identify indexers" do
|
108
|
-
des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
|
109
|
-
des.instance_members.select { |mem| mem.name == "get_Item" }.should_not be_empty
|
110
|
-
end
|
111
|
-
|
112
|
-
it "should correctly identify indexers" do
|
113
|
-
des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
|
114
|
-
des.instance_members.select { |mem| mem.name == "set_Item" }.should_not be_empty
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
context "when collecting events" do
|
119
|
-
|
120
|
-
before do
|
121
|
-
@des = Caricature::ClrInterfaceDescriptor.new ClrModels::IExplodingWarrior
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should have collected 2 events" do
|
125
|
-
@des.events.size.should == 2
|
126
|
-
end
|
127
|
-
|
128
|
-
it "should have collected 2 instance events" do
|
129
|
-
@des.events.all? { |ev| ev.instance_member? }.should be_true
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
|
136
|
-
describe "Caricature::ClrClassDescriptor" do
|
137
|
-
|
138
|
-
context "when collecting methods" do
|
139
|
-
|
140
|
-
before do
|
141
|
-
@des = Caricature::ClrClassDescriptor.new ClrModels::SwordWithStatics
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should have 11 instance members" do
|
145
|
-
@des.instance_members.size.should == 11
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should have 5 static members" do
|
149
|
-
@des.class_members.size.should == 5
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should have a damage instance member" do
|
153
|
-
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should have a another method instance member" do
|
157
|
-
@des.instance_members.select { |mem| mem.name == "another_method" }.should_not be_empty
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should correctly identify indexers" do
|
161
|
-
des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
|
162
|
-
des.instance_members.select { |mem| mem.name == "get_Item" }.should_not be_empty
|
163
|
-
end
|
164
|
-
|
165
|
-
it "should correctly identify indexers" do
|
166
|
-
des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
|
167
|
-
des.instance_members.select { |mem| mem.name == "set_Item" }.should_not be_empty
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
context "when collecting events" do
|
172
|
-
|
173
|
-
before do
|
174
|
-
@des = Caricature::ClrClassDescriptor.new ClrModels::ExposingWarrior
|
175
|
-
end
|
176
|
-
|
177
|
-
it "should have 2 instance events" do
|
178
|
-
@des.events.size.should == 2
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should should have 1 class event" do
|
182
|
-
@des.class_events.size.should == 1
|
183
|
-
end
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
describe "Caricature::RubyObjectDescriptor" do
|
190
|
-
|
191
|
-
before do
|
192
|
-
@des = Caricature::RubyObjectDescriptor.new DaggerWithClassMembers
|
193
|
-
end
|
194
|
-
|
195
|
-
it "should have 2 instance members" do
|
196
|
-
@des.instance_members.size.should == 2
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should have a damage instance member" do
|
200
|
-
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
201
|
-
end
|
202
|
-
|
203
|
-
it "should have 1 class member" do
|
204
|
-
@des.class_members.size.should == 1
|
205
|
-
end
|
206
|
-
|
207
|
-
it "should have a class_name class member" do
|
208
|
-
@des.class_members.select { |mem| mem.name == "class_name" }.should_not be_empty
|
209
|
-
end
|
210
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "Caricature::TypeDescriptor" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@des = Caricature::TypeDescriptor.new :in_unit_test_for_class
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have a class_members method" do
|
10
|
+
@des.should respond_to(:class_members)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return an empty collection for the class members" do
|
14
|
+
@des.class_members.should be_empty
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have an instance members method" do
|
18
|
+
@des.should respond_to(:instance_members)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return an empty collection for the instance members" do
|
22
|
+
@des.instance_members.should be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise a NotImplementedError for the initialize_instance_members method" do
|
26
|
+
lambda { @des.initialize_instance_members_for Soldier }.should raise_error(NotImplementedError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should raise a NotImplementedError for the initialize_class_members method" do
|
30
|
+
lambda { @des.initialize_class_members_for Soldier }.should raise_error(NotImplementedError)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "Caricature::MemberDescriptor" do
|
36
|
+
|
37
|
+
it "should have a name" do
|
38
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
39
|
+
des.name.should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have the correct name" do
|
43
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
44
|
+
des.name.should == 'a name'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have a return_type" do
|
48
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
49
|
+
des.return_type.should_not be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have the correct return_type" do
|
53
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
54
|
+
des.return_type.should == 'a type'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should say it's an instance type" do
|
58
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
59
|
+
des.should be_instance_member
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should say it's not an instance type" do
|
63
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type', false
|
64
|
+
des.should_not be_instance_member
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe Caricature::ClrEventDescriptor do
|
70
|
+
|
71
|
+
it "should have an event name" do
|
72
|
+
des = Caricature::ClrEventDescriptor.new "EventName"
|
73
|
+
des.event_name.should == "EventName"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should correctly identify when it's not an instance member" do
|
77
|
+
des = Caricature::ClrEventDescriptor.new "EventName", false
|
78
|
+
des.should_not be_instance_member
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
describe Caricature::ClrInterfaceDescriptor do
|
84
|
+
|
85
|
+
context "when collecting methods" do
|
86
|
+
before do
|
87
|
+
@des = Caricature::ClrInterfaceDescriptor.new ClrModels::IWeapon
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should have 2 instance members" do
|
91
|
+
@des.instance_members.size.should == 2
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should contain only instance members" do
|
95
|
+
result = true
|
96
|
+
@des.instance_members.each do |mem|
|
97
|
+
result = false unless mem.instance_member?
|
98
|
+
end
|
99
|
+
|
100
|
+
result.should be_true
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should have a damage instance member" do
|
104
|
+
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should correctly identify indexers" do
|
108
|
+
des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
|
109
|
+
des.instance_members.select { |mem| mem.name == "get_Item" }.should_not be_empty
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should correctly identify indexers" do
|
113
|
+
des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
|
114
|
+
des.instance_members.select { |mem| mem.name == "set_Item" }.should_not be_empty
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "when collecting events" do
|
119
|
+
|
120
|
+
before do
|
121
|
+
@des = Caricature::ClrInterfaceDescriptor.new ClrModels::IExplodingWarrior
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should have collected 2 events" do
|
125
|
+
@des.events.size.should == 2
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should have collected 2 instance events" do
|
129
|
+
@des.events.all? { |ev| ev.instance_member? }.should be_true
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "Caricature::ClrClassDescriptor" do
|
137
|
+
|
138
|
+
context "when collecting methods" do
|
139
|
+
|
140
|
+
before do
|
141
|
+
@des = Caricature::ClrClassDescriptor.new ClrModels::SwordWithStatics
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should have 11 instance members" do
|
145
|
+
@des.instance_members.size.should == 11
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should have 5 static members" do
|
149
|
+
@des.class_members.size.should == 5
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should have a damage instance member" do
|
153
|
+
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should have a another method instance member" do
|
157
|
+
@des.instance_members.select { |mem| mem.name == "another_method" }.should_not be_empty
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should correctly identify indexers" do
|
161
|
+
des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
|
162
|
+
des.instance_members.select { |mem| mem.name == "get_Item" }.should_not be_empty
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should correctly identify indexers" do
|
166
|
+
des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
|
167
|
+
des.instance_members.select { |mem| mem.name == "set_Item" }.should_not be_empty
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
context "when collecting events" do
|
172
|
+
|
173
|
+
before do
|
174
|
+
@des = Caricature::ClrClassDescriptor.new ClrModels::ExposingWarrior
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should have 2 instance events" do
|
178
|
+
@des.events.size.should == 2
|
179
|
+
end
|
180
|
+
|
181
|
+
it "should should have 1 class event" do
|
182
|
+
@des.class_events.size.should == 1
|
183
|
+
end
|
184
|
+
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
describe "Caricature::RubyObjectDescriptor" do
|
190
|
+
|
191
|
+
before do
|
192
|
+
@des = Caricature::RubyObjectDescriptor.new DaggerWithClassMembers
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should have 2 instance members" do
|
196
|
+
@des.instance_members.size.should == 2
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should have a damage instance member" do
|
200
|
+
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
201
|
+
end
|
202
|
+
|
203
|
+
it "should have 1 class member" do
|
204
|
+
@des.class_members.size.should == 1
|
205
|
+
end
|
206
|
+
|
207
|
+
it "should have a class_name class member" do
|
208
|
+
@des.class_members.select { |mem| mem.name == "class_name" }.should_not be_empty
|
209
|
+
end
|
210
|
+
|
211
211
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
-
|
3
|
-
describe "CLR event handling" do
|
4
|
-
|
5
|
-
context "for CLR interfaces" do
|
6
|
-
|
7
|
-
before do
|
8
|
-
@proxy = isolate ClrModels::IExplodingWarrior
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should not raise an error when subcribing to an event" do
|
12
|
-
lambda { ClrModels::ExposedChangedSubscriber.new(@proxy) }.should_not raise_error
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "CLR event handling" do
|
4
|
+
|
5
|
+
context "for CLR interfaces" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@proxy = isolate ClrModels::IExplodingWarrior
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not raise an error when subcribing to an event" do
|
12
|
+
lambda { ClrModels::ExposedChangedSubscriber.new(@proxy) }.should_not raise_error
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
17
|
end
|