module-cluster 1.3.7 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/README.md +146 -1
  2. data/README.rdoc +146 -1
  3. data/lib/module-cluster.rb +54 -12
  4. data/lib/module-cluster/ModuleCluster/Define/Block.rb +3 -0
  5. data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +16 -4
  6. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +63 -0
  7. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +2 -0
  8. data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +63 -0
  9. data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +32 -0
  10. data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +16 -4
  11. data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +63 -0
  12. data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +200 -0
  13. data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +127 -0
  14. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +7 -19
  15. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +5 -20
  16. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +9 -26
  17. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +9 -26
  18. data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +46 -0
  19. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +200 -0
  20. data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +208 -0
  21. data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +127 -0
  22. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +54 -0
  23. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +44 -0
  24. data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +209 -0
  25. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack.rb +0 -2
  26. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack/Block.rb +1 -2
  27. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +36 -0
  28. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +20 -0
  29. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +36 -0
  30. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +2 -0
  31. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +108 -0
  32. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +84 -0
  33. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +108 -0
  34. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +84 -0
  35. data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +7 -0
  36. data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ExtendForCascade.rb +0 -0
  37. data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +230 -0
  38. data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +238 -0
  39. data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +231 -0
  40. data/spec/ModuleCluster/Define/Block/Class_spec.rb +224 -0
  41. data/spec/ModuleCluster/Define/Block/Instance_spec.rb +78 -0
  42. data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +54 -0
  43. data/spec/ModuleCluster/Define/Block/Module_spec.rb +224 -0
  44. data/spec/ModuleCluster/Define/Block_spec.rb +18 -0
  45. data/spec/ModuleCluster/Define/ClassCluster_spec.rb +728 -0
  46. data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +576 -0
  47. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +298 -60
  48. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +307 -61
  49. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +335 -36
  50. data/spec/ModuleCluster/Define/Cluster_spec.rb +447 -14
  51. data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +102 -0
  52. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +728 -0
  53. data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +728 -0
  54. data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +576 -0
  55. data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +278 -0
  56. metadata +42 -13
  57. data/lib/module-cluster/ModuleCluster/CascadeFeatures.rb +0 -197
  58. data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
  59. data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
  60. data/lib/module-cluster/ModuleCluster/ClusterStack/Extends.rb +0 -29
  61. data/lib/module-cluster/ModuleCluster/ClusterStack/Includes.rb +0 -28
  62. data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -28
  63. data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -28
  64. data/lib/module-cluster/ModuleCluster/Define/ClusterStack.rb +0 -26
@@ -0,0 +1,576 @@
1
+
2
+ require_relative '../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::ClassOrInstanceCluster do
5
+
6
+ ####################################
7
+ # self.should_include_or_extend? #
8
+ ####################################
9
+
10
+ it 'should return true if class or instance, false otherwise' do
11
+ ModuleCluster::Define::ClassOrInstanceCluster.should_include_or_extend?( Kernel ).should == false
12
+ ModuleCluster::Define::ClassOrInstanceCluster.should_include_or_extend?( Class ).should == true
13
+ ModuleCluster::Define::ClassOrInstanceCluster.should_include_or_extend?( Object.new ).should == true
14
+ end
15
+
16
+ ##########################
17
+ # self.should_cascade? #
18
+ ##########################
19
+
20
+ it 'should report false' do
21
+ ModuleCluster::Define::ClassOrInstanceCluster.should_cascade?( Kernel ).should == false
22
+ ModuleCluster::Define::ClassOrInstanceCluster.should_cascade?( Class ).should == false
23
+ ModuleCluster::Define::ClassOrInstanceCluster.should_cascade?( Object.new ).should == false
24
+ end
25
+
26
+ #########################################################################
27
+ # class_include_or_extend_or_instance_extend_also_includes_or_extends #
28
+ #########################################################################
29
+
30
+ it 'can include a module when this one is included in a class or extend an instance when this one is used to extend an instance' do
31
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock01
32
+ extend ModuleCluster::Define::ClassOrInstanceCluster
33
+ module Module1
34
+ end
35
+ module Module2
36
+ end
37
+ class_include_or_extend_or_instance_extend_also_includes_or_extends( Module1, Module2 )
38
+ respond_to?( :included ).should == true
39
+ respond_to?( :extended ).should == true
40
+ module ModuleProof
41
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock01
42
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == false
43
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == false
44
+ eigenclass = class << self ; self ; end
45
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == false
46
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == false
47
+ end
48
+ module ModuleProof2
49
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock01
50
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == false
51
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == false
52
+ eigenclass = class << self ; self ; end
53
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == false
54
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == false
55
+ end
56
+ class ClassProof
57
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock01
58
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == true
59
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == true
60
+ eigenclass = class << self ; self ; end
61
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == false
62
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == false
63
+ end
64
+ class ClassProof2
65
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock01
66
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == false
67
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == false
68
+ eigenclass = class << self ; self ; end
69
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == true
70
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == true
71
+ end
72
+ Object.new.instance_eval do
73
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock01
74
+ eigenclass = class << self ; self ; end
75
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module1 ).should == true
76
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock01::Module2 ).should == true
77
+ end
78
+ end
79
+ end
80
+
81
+ #############################################################
82
+ # class_include_or_extend_or_instance_extend_also_extends #
83
+ #############################################################
84
+
85
+ it 'can include a module when this one is included in a class or extend with another module when this one is used to extend a class or extend an instance when this one is used to extend an instance' do
86
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock02
87
+ extend ModuleCluster::Define::ClassOrInstanceCluster
88
+ module Module1
89
+ end
90
+ module Module2
91
+ end
92
+ class_include_or_extend_or_instance_extend_also_extends( Module1, Module2 )
93
+ respond_to?( :included ).should == true
94
+ respond_to?( :extended ).should == true
95
+ module ModuleProof
96
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock02
97
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == false
98
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == false
99
+ eigenclass = class << self ; self ; end
100
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == false
101
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == false
102
+ end
103
+ module ModuleProof2
104
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock02
105
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == false
106
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == false
107
+ eigenclass = class << self ; self ; end
108
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == false
109
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == false
110
+ end
111
+ class ClassProof
112
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock02
113
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == false
114
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == false
115
+ eigenclass = class << self ; self ; end
116
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == true
117
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == true
118
+ end
119
+ class ClassProof2
120
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock02
121
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == false
122
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == false
123
+ eigenclass = class << self ; self ; end
124
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == true
125
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == true
126
+ end
127
+ Object.new.instance_eval do
128
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock02
129
+ eigenclass = class << self ; self ; end
130
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module1 ).should == true
131
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock02::Module2 ).should == true
132
+ end
133
+ end
134
+ end
135
+
136
+ ###############################################################
137
+ # class_include_or_instance_extend_also_includes_or_extends #
138
+ ###############################################################
139
+
140
+ it 'can include a module when this one is included in a class or extend with another module when this one is used to extend an instance' do
141
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock03
142
+ extend ModuleCluster::Define::ClassOrInstanceCluster
143
+ module Module1
144
+ end
145
+ module Module2
146
+ end
147
+ class_include_or_instance_extend_also_includes_or_extends( Module1, Module2 )
148
+ respond_to?( :included ).should == true
149
+ respond_to?( :extended ).should == true
150
+ module ModuleProof
151
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock03
152
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == false
153
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == false
154
+ eigenclass = class << self ; self ; end
155
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == false
156
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == false
157
+ end
158
+ module ModuleProof2
159
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock03
160
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == false
161
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == false
162
+ eigenclass = class << self ; self ; end
163
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == false
164
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == false
165
+ end
166
+ class ClassProof
167
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock03
168
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == true
169
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == true
170
+ eigenclass = class << self ; self ; end
171
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == false
172
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == false
173
+ end
174
+ class ClassProof2
175
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock03
176
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == false
177
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == false
178
+ eigenclass = class << self ; self ; end
179
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == false
180
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == false
181
+ end
182
+ Object.new.instance_eval do
183
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock03
184
+ eigenclass = class << self ; self ; end
185
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module1 ).should == true
186
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock03::Module2 ).should == true
187
+ end
188
+ end
189
+ end
190
+
191
+ ###################################################
192
+ # class_include_or_instance_extend_also_extends #
193
+ ###################################################
194
+
195
+ it 'can extend with another module when this one is included in a class or used to extend an instance' do
196
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock04
197
+ extend ModuleCluster::Define::ClassOrInstanceCluster
198
+ module Module1
199
+ end
200
+ module Module2
201
+ end
202
+ class_include_or_instance_extend_also_extends( Module1, Module2 )
203
+ respond_to?( :included ).should == true
204
+ respond_to?( :extended ).should == true
205
+ module ModuleProof
206
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock04
207
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == false
208
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == false
209
+ eigenclass = class << self ; self ; end
210
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == false
211
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == false
212
+ end
213
+ module ModuleProof2
214
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock04
215
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == false
216
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == false
217
+ eigenclass = class << self ; self ; end
218
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == false
219
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == false
220
+ end
221
+ class ClassProof
222
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock04
223
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == false
224
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == false
225
+ eigenclass = class << self ; self ; end
226
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == true
227
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == true
228
+ end
229
+ class ClassProof2
230
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock04
231
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == false
232
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == false
233
+ eigenclass = class << self ; self ; end
234
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == false
235
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == false
236
+ end
237
+ Object.new.instance_eval do
238
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock04
239
+ eigenclass = class << self ; self ; end
240
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module1 ).should == true
241
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock04::Module2 ).should == true
242
+ end
243
+ end
244
+ end
245
+
246
+ ###########################################
247
+ # class_or_instance_extend_also_extends #
248
+ ###########################################
249
+
250
+ it 'can extend with another module when this one is used to extend a class or instance' do
251
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock05
252
+ extend ModuleCluster::Define::ClassOrInstanceCluster
253
+ module Module1
254
+ end
255
+ module Module2
256
+ end
257
+ class_or_instance_extend_also_extends( Module1, Module2 )
258
+ respond_to?( :included ).should == true
259
+ respond_to?( :extended ).should == true
260
+ module ModuleProof
261
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock05
262
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == false
263
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == false
264
+ eigenclass = class << self ; self ; end
265
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == false
266
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == false
267
+ end
268
+ module ModuleProof2
269
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock05
270
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == false
271
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == false
272
+ eigenclass = class << self ; self ; end
273
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == false
274
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == false
275
+ end
276
+ class ClassProof
277
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock05
278
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == false
279
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == false
280
+ eigenclass = class << self ; self ; end
281
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == false
282
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == false
283
+ end
284
+ class ClassProof2
285
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock05
286
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == false
287
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == false
288
+ eigenclass = class << self ; self ; end
289
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == true
290
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == true
291
+ end
292
+ Object.new.instance_eval do
293
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock05
294
+ eigenclass = class << self ; self ; end
295
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module1 ).should == true
296
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock05::Module2 ).should == true
297
+ end
298
+ end
299
+ end
300
+
301
+ #############################################################################
302
+ # class_include_or_extend_or_instance_extend_prepends_includes_or_extends #
303
+ #############################################################################
304
+
305
+ it 'can include a module before this one is included in a class or extend an instance before this one is used to extend an instance' do
306
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock06
307
+ extend ModuleCluster::Define::ClassOrInstanceCluster
308
+ module Module1
309
+ end
310
+ module Module2
311
+ end
312
+ class_include_or_extend_or_instance_extend_prepends_includes_or_extends( Module1, Module2 )
313
+ respond_to?( :included ).should == true
314
+ respond_to?( :extended ).should == true
315
+ module ModuleProof
316
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock06
317
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == false
318
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == false
319
+ eigenclass = class << self ; self ; end
320
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == false
321
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == false
322
+ end
323
+ module ModuleProof2
324
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock06
325
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == false
326
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == false
327
+ eigenclass = class << self ; self ; end
328
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == false
329
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == false
330
+ end
331
+ class ClassProof
332
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock06
333
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == true
334
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == true
335
+ eigenclass = class << self ; self ; end
336
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == false
337
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == false
338
+ end
339
+ class ClassProof2
340
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock06
341
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == false
342
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == false
343
+ eigenclass = class << self ; self ; end
344
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == true
345
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == true
346
+ end
347
+ Object.new.instance_eval do
348
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock06
349
+ eigenclass = class << self ; self ; end
350
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module1 ).should == true
351
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock06::Module2 ).should == true
352
+ end
353
+ end
354
+ end
355
+
356
+ ###################################################################
357
+ # class_include_or_instance_extend_prepends_includes_or_extends #
358
+ ###################################################################
359
+
360
+ it 'can include a module before this one is included in a class or extend with another module before this one is used to extend a class or extend an instance before this one is used to extend an instance' do
361
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock07
362
+ extend ModuleCluster::Define::ClassOrInstanceCluster
363
+ module Module1
364
+ end
365
+ module Module2
366
+ end
367
+ class_include_or_instance_extend_prepends_includes_or_extends( Module1, Module2 )
368
+ respond_to?( :included ).should == true
369
+ respond_to?( :extended ).should == true
370
+ module ModuleProof
371
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock07
372
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == false
373
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == false
374
+ eigenclass = class << self ; self ; end
375
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == false
376
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == false
377
+ end
378
+ module ModuleProof2
379
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock07
380
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == false
381
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == false
382
+ eigenclass = class << self ; self ; end
383
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == false
384
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == false
385
+ end
386
+ class ClassProof
387
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock07
388
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == true
389
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == true
390
+ eigenclass = class << self ; self ; end
391
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == false
392
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == false
393
+ end
394
+ class ClassProof2
395
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock07
396
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == false
397
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == false
398
+ eigenclass = class << self ; self ; end
399
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == false
400
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == false
401
+ end
402
+ Object.new.instance_eval do
403
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock07
404
+ eigenclass = class << self ; self ; end
405
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module1 ).should == true
406
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock07::Module2 ).should == true
407
+ end
408
+ end
409
+ end
410
+
411
+ #################################################################
412
+ # class_include_or_extend_or_instance_extend_prepends_extends #
413
+ #################################################################
414
+
415
+ it 'can include a module before this one is included in a class or extend with another module before this one is used to extend an instance' do
416
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock08
417
+ extend ModuleCluster::Define::ClassOrInstanceCluster
418
+ module Module1
419
+ end
420
+ module Module2
421
+ end
422
+ class_include_or_extend_or_instance_extend_prepends_extends( Module1, Module2 )
423
+ respond_to?( :included ).should == true
424
+ respond_to?( :extended ).should == true
425
+ module ModuleProof
426
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock08
427
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == false
428
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == false
429
+ eigenclass = class << self ; self ; end
430
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == false
431
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == false
432
+ end
433
+ module ModuleProof2
434
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock08
435
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == false
436
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == false
437
+ eigenclass = class << self ; self ; end
438
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == false
439
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == false
440
+ end
441
+ class ClassProof
442
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock08
443
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == true
444
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == true
445
+ eigenclass = class << self ; self ; end
446
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == false
447
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == false
448
+ end
449
+ class ClassProof2
450
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock08
451
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == false
452
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == false
453
+ eigenclass = class << self ; self ; end
454
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == false
455
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == false
456
+ end
457
+ Object.new.instance_eval do
458
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock08
459
+ eigenclass = class << self ; self ; end
460
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module1 ).should == true
461
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock08::Module2 ).should == true
462
+ end
463
+ end
464
+ end
465
+
466
+ #######################################################
467
+ # class_include_or_instance_extend_prepends_extends #
468
+ #######################################################
469
+
470
+ it 'can extend with another module before this one is included in a class or used to extend an instance' do
471
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock09
472
+ extend ModuleCluster::Define::ClassOrInstanceCluster
473
+ module Module1
474
+ end
475
+ module Module2
476
+ end
477
+ class_include_or_instance_extend_prepends_extends( Module1, Module2 )
478
+ respond_to?( :included ).should == true
479
+ respond_to?( :extended ).should == true
480
+ module ModuleProof
481
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock09
482
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == false
483
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == false
484
+ eigenclass = class << self ; self ; end
485
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == false
486
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == false
487
+ end
488
+ module ModuleProof2
489
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock09
490
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == false
491
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == false
492
+ eigenclass = class << self ; self ; end
493
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == false
494
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == false
495
+ end
496
+ class ClassProof
497
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock09
498
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == false
499
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == false
500
+ eigenclass = class << self ; self ; end
501
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == true
502
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == true
503
+ end
504
+ class ClassProof2
505
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock09
506
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == false
507
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == false
508
+ eigenclass = class << self ; self ; end
509
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == false
510
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == false
511
+ end
512
+ Object.new.instance_eval do
513
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock09
514
+ eigenclass = class << self ; self ; end
515
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module1 ).should == true
516
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock09::Module2 ).should == true
517
+ end
518
+ end
519
+ end
520
+
521
+ ###############################################
522
+ # class_or_instance_extend_prepends_extends #
523
+ ###############################################
524
+
525
+ it 'can extend with another module before this one is used to extend a class or instance' do
526
+ module ModuleCluster::Define::ClassOrInstanceCluster::Mock10
527
+ extend ModuleCluster::Define::ClassOrInstanceCluster
528
+ module Module1
529
+ end
530
+ module Module2
531
+ end
532
+ class_or_instance_extend_prepends_extends( Module1, Module2 )
533
+ respond_to?( :included ).should == true
534
+ respond_to?( :extended ).should == true
535
+ module ModuleProof
536
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock10
537
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == false
538
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == false
539
+ eigenclass = class << self ; self ; end
540
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == false
541
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == false
542
+ end
543
+ module ModuleProof2
544
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock10
545
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == false
546
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == false
547
+ eigenclass = class << self ; self ; end
548
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == false
549
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == false
550
+ end
551
+ class ClassProof
552
+ include ModuleCluster::Define::ClassOrInstanceCluster::Mock10
553
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == false
554
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == false
555
+ eigenclass = class << self ; self ; end
556
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == false
557
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == false
558
+ end
559
+ class ClassProof2
560
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock10
561
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == false
562
+ ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == false
563
+ eigenclass = class << self ; self ; end
564
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == true
565
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == true
566
+ end
567
+ Object.new.instance_eval do
568
+ extend ModuleCluster::Define::ClassOrInstanceCluster::Mock10
569
+ eigenclass = class << self ; self ; end
570
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module1 ).should == true
571
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClassOrInstanceCluster::Mock10::Module2 ).should == true
572
+ end
573
+ end
574
+ end
575
+
576
+ end