module-cluster 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. data/lib/module-cluster.rb +17 -13
  2. data/lib/module-cluster/ModuleCluster.rb +8 -8
  3. data/lib/module-cluster/ModuleCluster/CascadeFeatures.rb +155 -0
  4. data/lib/module-cluster/ModuleCluster/ClusterStack.rb +102 -0
  5. data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +203 -0
  6. data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +220 -0
  7. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +209 -0
  8. data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +209 -0
  9. data/lib/module-cluster/ModuleCluster/Define/ClusterStack.rb +26 -0
  10. data/lib/module-cluster/ModuleCluster/Define/DedoubleAncestors.rb +22 -0
  11. data/lib/module-cluster/ModuleCluster/ExtendForCascade.rb +15 -0
  12. data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +421 -0
  13. data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +432 -0
  14. data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +345 -0
  15. data/spec/ModuleCluster/Define/Cluster_spec.rb +275 -0
  16. data/spec/ModuleCluster_spec.rb +4 -4
  17. metadata +16 -14
  18. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +0 -211
  19. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascades.rb +0 -223
  20. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToClass.rb +0 -223
  21. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToModule.rb +0 -227
  22. data/lib/module-cluster/ModuleCluster/Define/_private_/AnonymousModule.rb +0 -121
  23. data/lib/module-cluster/ModuleCluster/Define/_private_/ClusterStack.rb +0 -55
  24. data/spec/ModuleCluster/Define/ModuleClusterCascadesToClass_spec.rb +0 -421
  25. data/spec/ModuleCluster/Define/ModuleClusterCascadesToModule_spec.rb +0 -432
  26. data/spec/ModuleCluster/Define/ModuleClusterCascades_spec.rb +0 -345
  27. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +0 -275
  28. data/spec/ModuleCluster/Define/_private_/ClusterStack_spec.rb +0 -24
@@ -0,0 +1,432 @@
1
+
2
+ require_relative '../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::ClusterCascadesToModule do
5
+
6
+ #########################################
7
+ # include_cascades_includes_to_module #
8
+ #########################################
9
+
10
+ it 'include modules for any class this module or any including modules are included in' do
11
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock01
12
+ extend ModuleCluster::Define::ClusterCascadesToModule
13
+ module Module1
14
+ end
15
+ module Module2
16
+ end
17
+ include_cascades_includes_to_module( Module1, Module2 )
18
+ respond_to?( :included ).should == true
19
+ module Proof1
20
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock01
21
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock01::Module1 ).should == true
22
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock01::Module2 ).should == true
23
+ end
24
+ module Proof2
25
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock01::Proof1
26
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock01::Module1 ).should == true
27
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock01::Module2 ).should == true
28
+ end
29
+ class Proof3
30
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock01::Proof2
31
+ # true b/c of ancestor chain
32
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock01::Module1 ).should == true
33
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock01::Module2 ).should == true
34
+ end
35
+ end
36
+ end
37
+
38
+ ########################################
39
+ # include_cascades_extends_to_module #
40
+ ########################################
41
+
42
+ it 'extends modules for any class this module or any including modules are included in' do
43
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock02
44
+ extend ModuleCluster::Define::ClusterCascadesToModule
45
+ module Module1
46
+ end
47
+ module Module2
48
+ end
49
+ include_cascades_extends_to_module( Module1, Module2 )
50
+ respond_to?( :included ).should == true
51
+ module Proof1
52
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock02
53
+ eigenclass = class << self ; self ; end
54
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock02::Module1 ).should == true
55
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock02::Module2 ).should == true
56
+ end
57
+ module Proof2
58
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock02::Proof1
59
+ eigenclass = class << self ; self ; end
60
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock02::Module1 ).should == true
61
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock02::Module2 ).should == true
62
+ end
63
+ class Proof3
64
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock02::Proof2
65
+ eigenclass = class << self ; self ; end
66
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock02::Module1 ).should == false
67
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock02::Module2 ).should == false
68
+ end
69
+ end
70
+ end
71
+
72
+ #####################################################
73
+ # include_cascades_includes_and_extends_to_module #
74
+ #####################################################
75
+
76
+ it 'include and extends modules for any class this module or any including modules are included in' do
77
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock03
78
+ extend ModuleCluster::Define::ClusterCascadesToModule
79
+ module Module1
80
+ end
81
+ module Module2
82
+ end
83
+ include_cascades_includes_and_extends_to_module( Module1, Module2 )
84
+ respond_to?( :included ).should == true
85
+ module Proof1
86
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock03
87
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module1 ).should == true
88
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module2 ).should == true
89
+ eigenclass = class << self ; self ; end
90
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module1 ).should == true
91
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module2 ).should == true
92
+ end
93
+ module Proof2
94
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock03::Proof1
95
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module1 ).should == true
96
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module2 ).should == true
97
+ eigenclass = class << self ; self ; end
98
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module1 ).should == true
99
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module2 ).should == true
100
+ end
101
+ class Proof3
102
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock03::Proof2
103
+ # true b/c of ancestor chain
104
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module1 ).should == true
105
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module2 ).should == true
106
+ eigenclass = class << self ; self ; end
107
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module1 ).should == false
108
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock03::Module2 ).should == false
109
+ end
110
+ end
111
+ end
112
+
113
+ ########################################
114
+ # extend_cascades_includes_to_module #
115
+ ########################################
116
+
117
+ it 'include modules for any class this module is extended in' do
118
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock04
119
+ extend ModuleCluster::Define::ClusterCascadesToModule
120
+ module Module1
121
+ end
122
+ module Module2
123
+ end
124
+ extend_cascades_includes_to_module( Module1, Module2 )
125
+ respond_to?( :extended ).should == true
126
+ module Proof1
127
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock04
128
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock04::Module1 ).should == true
129
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock04::Module2 ).should == true
130
+ end
131
+ module Proof2
132
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock04::Proof1
133
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock04::Module1 ).should == true
134
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock04::Module2 ).should == true
135
+ end
136
+ class Proof3
137
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock04::Proof2
138
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock04::Module1 ).should == false
139
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock04::Module2 ).should == false
140
+ end
141
+ end
142
+ end
143
+
144
+ #######################################
145
+ # extend_cascades_extends_to_module #
146
+ #######################################
147
+
148
+ it 'extend modules for any class this module is extended in' do
149
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock05
150
+ extend ModuleCluster::Define::ClusterCascadesToModule
151
+ module Module1
152
+ end
153
+ module Module2
154
+ end
155
+ extend_cascades_extends_to_module( Module1, Module2 )
156
+ respond_to?( :extended ).should == true
157
+ module Proof1
158
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock05
159
+ eigenclass = class << self ; self ; end
160
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock05::Module1 ).should == true
161
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock05::Module2 ).should == true
162
+ end
163
+ module Proof2
164
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock05::Proof1
165
+ eigenclass = class << self ; self ; end
166
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock05::Module1 ).should == true
167
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock05::Module2 ).should == true
168
+ end
169
+ class Proof3
170
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock05::Proof2
171
+ eigenclass = class << self ; self ; end
172
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock05::Module1 ).should == false
173
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock05::Module2 ).should == false
174
+ end
175
+ end
176
+ end
177
+
178
+ ####################################################
179
+ # extend_cascades_includes_and_extends_to_module #
180
+ ####################################################
181
+
182
+ it 'include and extend modules for any class this module is extended in' do
183
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock06
184
+ extend ModuleCluster::Define::ClusterCascadesToModule
185
+ module Module1
186
+ end
187
+ module Module2
188
+ end
189
+ extend_cascades_includes_and_extends_to_module( Module1, Module2 )
190
+ respond_to?( :extended ).should == true
191
+ module Proof1
192
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock06
193
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module1 ).should == true
194
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module2 ).should == true
195
+ eigenclass = class << self ; self ; end
196
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module1 ).should == true
197
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module2 ).should == true
198
+ end
199
+ module Proof2
200
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock06::Proof1
201
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module1 ).should == true
202
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module2 ).should == true
203
+ eigenclass = class << self ; self ; end
204
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module1 ).should == true
205
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module2 ).should == true
206
+ end
207
+ class Proof3
208
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock06::Proof2
209
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module1 ).should == false
210
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module2 ).should == false
211
+ eigenclass = class << self ; self ; end
212
+ # true because Proof2's ancestor chain includes
213
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module1 ).should == true
214
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock06::Module2 ).should == true
215
+ end
216
+ end
217
+ end
218
+
219
+ ####################################################
220
+ # include_cascades_to_module_prepending_includes #
221
+ ####################################################
222
+
223
+ it 'include other modules for any class this module or any including modules are included in, before this module or including module is included' do
224
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock07
225
+ extend ModuleCluster::Define::ClusterCascadesToModule
226
+ module Module1
227
+ end
228
+ module Module2
229
+ end
230
+ include_cascades_to_module_prepending_includes( Module1, Module2 )
231
+ respond_to?( :append_features ).should == true
232
+ module Proof1
233
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock07
234
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock07::Module1 ).should == true
235
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock07::Module2 ).should == true
236
+ end
237
+ module Proof2
238
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock07::Proof1
239
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock07::Module1 ).should == true
240
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock07::Module2 ).should == true
241
+ end
242
+ class Proof3
243
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock07::Proof2
244
+ # true b/c of ancestor chain
245
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock07::Module1 ).should == true
246
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock07::Module2 ).should == true
247
+ end
248
+ end
249
+ end
250
+
251
+ ###################################################
252
+ # include_cascades_to_module_prepending_extends #
253
+ ###################################################
254
+
255
+ it 'extend other modules for any class this module or any including modules are included in, before this module or including module is included' do
256
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock08
257
+ extend ModuleCluster::Define::ClusterCascadesToModule
258
+ module Module1
259
+ end
260
+ module Module2
261
+ end
262
+ include_cascades_to_module_prepending_extends( Module1, Module2 )
263
+ respond_to?( :append_features ).should == true
264
+ module Proof1
265
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock08
266
+ eigenclass = class << self ; self ; end
267
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock08::Module1 ).should == true
268
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock08::Module2 ).should == true
269
+ end
270
+ module Proof2
271
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock08::Proof1
272
+ eigenclass = class << self ; self ; end
273
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock08::Module1 ).should == true
274
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock08::Module2 ).should == true
275
+ end
276
+ class Proof3
277
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock08::Proof2
278
+ eigenclass = class << self ; self ; end
279
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock08::Module1 ).should == false
280
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock08::Module2 ).should == false
281
+ end
282
+ end
283
+ end
284
+
285
+ ################################################################
286
+ # include_cascades_to_module_prepending_includes_and_extends #
287
+ ################################################################
288
+
289
+ it 'include and extend other modules for any class this module or any including modules are included in, before this module or including module is included' do
290
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock09
291
+ extend ModuleCluster::Define::ClusterCascadesToModule
292
+ module Module1
293
+ end
294
+ module Module2
295
+ end
296
+ include_cascades_to_module_prepending_includes_and_extends( Module1, Module2 )
297
+ respond_to?( :append_features ).should == true
298
+ module Proof1
299
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock09
300
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module1 ).should == true
301
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module2 ).should == true
302
+ eigenclass = class << self ; self ; end
303
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module1 ).should == true
304
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module2 ).should == true
305
+ end
306
+ module Proof2
307
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock09::Proof1
308
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module1 ).should == true
309
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module2 ).should == true
310
+ eigenclass = class << self ; self ; end
311
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module1 ).should == true
312
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module2 ).should == true
313
+ end
314
+ class Proof3
315
+ include ModuleCluster::Define::ClusterCascadesToModule::Mock09::Proof2
316
+ # true b/c of ancestor chain
317
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module1 ).should == true
318
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module2 ).should == true
319
+ eigenclass = class << self ; self ; end
320
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module1 ).should == false
321
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock09::Module2 ).should == false
322
+ end
323
+ end
324
+ end
325
+
326
+ ###################################################
327
+ # extend_cascades_to_module_prepending_includes #
328
+ ###################################################
329
+
330
+ it 'include other modules for any class this module or any including modules are included in, before this module is extended' do
331
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock10
332
+ extend ModuleCluster::Define::ClusterCascadesToModule
333
+ module Module1
334
+ end
335
+ module Module2
336
+ end
337
+ extend_cascades_to_module_prepending_includes( Module1, Module2 )
338
+ respond_to?( :extend_object ).should == true
339
+ module Proof1
340
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock10
341
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock10::Module1 ).should == true
342
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock10::Module2 ).should == true
343
+ end
344
+ module Proof2
345
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock10::Proof1
346
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock10::Module1 ).should == true
347
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock10::Module2 ).should == true
348
+ end
349
+ class Proof3
350
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock10::Proof2
351
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock10::Module1 ).should == false
352
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock10::Module2 ).should == false
353
+ end
354
+ end
355
+ end
356
+
357
+ ##################################################
358
+ # extend_cascades_to_module_prepending_extends #
359
+ ##################################################
360
+
361
+ it 'extend other modules for any class this module or any including modules are included in, before this module is extended' do
362
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock11
363
+ extend ModuleCluster::Define::ClusterCascadesToModule
364
+ module Module1
365
+ end
366
+ module Module2
367
+ end
368
+ extend_cascades_to_module_prepending_extends( Module1, Module2 )
369
+ respond_to?( :extend_object ).should == true
370
+ module Proof1
371
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock11
372
+ eigenclass = class << self ; self ; end
373
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock11::Module1 ).should == true
374
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock11::Module2 ).should == true
375
+ end
376
+ module Proof2
377
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock11::Proof1
378
+ eigenclass = class << self ; self ; end
379
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock11::Module1 ).should == true
380
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock11::Module2 ).should == true
381
+ end
382
+ class Proof3
383
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock11::Proof2
384
+ eigenclass = class << self ; self ; end
385
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock11::Module1 ).should == false
386
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock11::Module2 ).should == false
387
+ end
388
+ end
389
+ end
390
+
391
+ ###############################################################
392
+ # extend_cascades_to_module_prepending_includes_and_extends #
393
+ ###############################################################
394
+
395
+ it 'include and extend other modules for any class this module or any including modules are included in, before this module is extended' do
396
+ module ModuleCluster::Define::ClusterCascadesToModule::Mock12
397
+ extend ModuleCluster::Define::ClusterCascadesToModule
398
+ module Module1
399
+ end
400
+ module Module2
401
+ end
402
+ extend_cascades_to_module_prepending_includes_and_extends( Module1, Module2 )
403
+ respond_to?( :extend_object ).should == true
404
+ module Proof1
405
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock12
406
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module1 ).should == true
407
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module2 ).should == true
408
+ eigenclass = class << self ; self ; end
409
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module1 ).should == true
410
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module2 ).should == true
411
+ end
412
+ module Proof2
413
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock12::Proof1
414
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module1 ).should == true
415
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module2 ).should == true
416
+ eigenclass = class << self ; self ; end
417
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module1 ).should == true
418
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module2 ).should == true
419
+ end
420
+ class Proof3
421
+ extend ModuleCluster::Define::ClusterCascadesToModule::Mock12::Proof2
422
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module1 ).should == false
423
+ ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module2 ).should == false
424
+ eigenclass = class << self ; self ; end
425
+ # true b/c Proof2's ancestors include
426
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module1 ).should == true
427
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascadesToModule::Mock12::Module2 ).should == true
428
+ end
429
+ end
430
+ end
431
+
432
+ end
@@ -0,0 +1,345 @@
1
+
2
+ require_relative '../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::ClusterCascades do
5
+
6
+ ###############################
7
+ # include_cascades_includes #
8
+ ###############################
9
+
10
+ it 'include modules for any class or module this module is included in' do
11
+ module ModuleCluster::Define::ClusterCascades::Mock01
12
+ extend ModuleCluster::Define::ClusterCascades
13
+ module Module1
14
+ end
15
+ module Module2
16
+ end
17
+ include_cascades_includes( Module1, Module2 )
18
+ respond_to?( :included ).should == true
19
+ module Proof1
20
+ include ModuleCluster::Define::ClusterCascades::Mock01
21
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock01::Module1 ).should == true
22
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock01::Module2 ).should == true
23
+ end
24
+ module Proof2
25
+ include ModuleCluster::Define::ClusterCascades::Mock01::Proof1
26
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock01::Module1 ).should == true
27
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock01::Module2 ).should == true
28
+ end
29
+ end
30
+ end
31
+
32
+ ##############################
33
+ # include_cascades_extends #
34
+ ##############################
35
+
36
+ it 'extends modules for any class or module this module is included in' do
37
+ module ModuleCluster::Define::ClusterCascades::Mock02
38
+ extend ModuleCluster::Define::ClusterCascades
39
+ module Module1
40
+ end
41
+ module Module2
42
+ end
43
+ include_cascades_extends( Module1, Module2 )
44
+ respond_to?( :included ).should == true
45
+ module Proof1
46
+ include ModuleCluster::Define::ClusterCascades::Mock02
47
+ eigenclass = class << self ; self ; end
48
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock02::Module1 ).should == true
49
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock02::Module2 ).should == true
50
+ end
51
+ module Proof2
52
+ include ModuleCluster::Define::ClusterCascades::Mock02::Proof1
53
+ eigenclass = class << self ; self ; end
54
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock02::Module1 ).should == true
55
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock02::Module2 ).should == true
56
+ end
57
+ end
58
+ end
59
+
60
+ ###########################################
61
+ # include_cascades_includes_and_extends #
62
+ ###########################################
63
+
64
+ it 'include and extends modules for any class or module this module is included in' do
65
+ module ModuleCluster::Define::ClusterCascades::Mock03
66
+ extend ModuleCluster::Define::ClusterCascades
67
+ module Module1
68
+ end
69
+ module Module2
70
+ end
71
+ include_cascades_includes_and_extends( Module1, Module2 )
72
+ respond_to?( :included ).should == true
73
+ module Proof1
74
+ include ModuleCluster::Define::ClusterCascades::Mock03
75
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module1 ).should == true
76
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module2 ).should == true
77
+ eigenclass = class << self ; self ; end
78
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module1 ).should == true
79
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module2 ).should == true
80
+ end
81
+ module Proof2
82
+ include ModuleCluster::Define::ClusterCascades::Mock03::Proof1
83
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module1 ).should == true
84
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module2 ).should == true
85
+ eigenclass = class << self ; self ; end
86
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module1 ).should == true
87
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock03::Module2 ).should == true
88
+ end
89
+ end
90
+ end
91
+
92
+ ##############################
93
+ # extend_cascades_includes #
94
+ ##############################
95
+
96
+ it 'include modules for any class or module this module is extended in' do
97
+ module ModuleCluster::Define::ClusterCascades::Mock04
98
+ extend ModuleCluster::Define::ClusterCascades
99
+ module Module1
100
+ end
101
+ module Module2
102
+ end
103
+ extend_cascades_includes( Module1, Module2 )
104
+ respond_to?( :extended ).should == true
105
+ module Proof1
106
+ extend ModuleCluster::Define::ClusterCascades::Mock04
107
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock04::Module1 ).should == true
108
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock04::Module2 ).should == true
109
+ end
110
+ module Proof2
111
+ extend ModuleCluster::Define::ClusterCascades::Mock04::Proof1
112
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock04::Module1 ).should == true
113
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock04::Module2 ).should == true
114
+ end
115
+ end
116
+ end
117
+
118
+ #############################
119
+ # extend_cascades_extends #
120
+ #############################
121
+
122
+ it 'extend modules for any class or module this module is extended in' do
123
+ module ModuleCluster::Define::ClusterCascades::Mock05
124
+ extend ModuleCluster::Define::ClusterCascades
125
+ module Module1
126
+ end
127
+ module Module2
128
+ end
129
+ extend_cascades_extends( Module1, Module2 )
130
+ respond_to?( :extended ).should == true
131
+ module Proof1
132
+ extend ModuleCluster::Define::ClusterCascades::Mock05
133
+ eigenclass = class << self ; self ; end
134
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock05::Module1 ).should == true
135
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock05::Module2 ).should == true
136
+ end
137
+ module Proof2
138
+ extend ModuleCluster::Define::ClusterCascades::Mock05::Proof1
139
+ eigenclass = class << self ; self ; end
140
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock05::Module1 ).should == true
141
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock05::Module2 ).should == true
142
+ end
143
+ end
144
+ end
145
+
146
+ ##########################################
147
+ # extend_cascades_includes_and_extends #
148
+ ##########################################
149
+
150
+ it 'include and extend modules for any class or module this module is extended in' do
151
+ module ModuleCluster::Define::ClusterCascades::Mock06
152
+ extend ModuleCluster::Define::ClusterCascades
153
+ module Module1
154
+ end
155
+ module Module2
156
+ end
157
+ extend_cascades_includes_and_extends( Module1, Module2 )
158
+ respond_to?( :extended ).should == true
159
+ module Proof1
160
+ extend ModuleCluster::Define::ClusterCascades::Mock06
161
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module1 ).should == true
162
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module2 ).should == true
163
+ eigenclass = class << self ; self ; end
164
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module1 ).should == true
165
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module2 ).should == true
166
+ end
167
+ module Proof2
168
+ extend ModuleCluster::Define::ClusterCascades::Mock06::Proof1
169
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module1 ).should == true
170
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module2 ).should == true
171
+ eigenclass = class << self ; self ; end
172
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module1 ).should == true
173
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock06::Module2 ).should == true
174
+ end
175
+ end
176
+ end
177
+
178
+ ##########################################
179
+ # include_cascades_prepending_includes #
180
+ ##########################################
181
+
182
+ it 'include other modules for any class or module this module is included in, before this module is included' do
183
+ module ModuleCluster::Define::ClusterCascades::Mock07
184
+ extend ModuleCluster::Define::ClusterCascades
185
+ module Module1
186
+ end
187
+ module Module2
188
+ end
189
+ include_cascades_prepending_includes( Module1, Module2 )
190
+ respond_to?( :append_features ).should == true
191
+ module Proof1
192
+ include ModuleCluster::Define::ClusterCascades::Mock07
193
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock07::Module1 ).should == true
194
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock07::Module2 ).should == true
195
+ end
196
+ module Proof2
197
+ include ModuleCluster::Define::ClusterCascades::Mock07::Proof1
198
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock07::Module1 ).should == true
199
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock07::Module2 ).should == true
200
+ end
201
+ end
202
+ end
203
+
204
+ #########################################
205
+ # include_cascades_prepending_extends #
206
+ #########################################
207
+
208
+ it 'extend other modules for any class or module this module is included in, before this module is included' do
209
+ module ModuleCluster::Define::ClusterCascades::Mock08
210
+ extend ModuleCluster::Define::ClusterCascades
211
+ module Module1
212
+ end
213
+ module Module2
214
+ end
215
+ include_cascades_prepending_extends( Module1, Module2 )
216
+ respond_to?( :append_features ).should == true
217
+ module Proof1
218
+ include ModuleCluster::Define::ClusterCascades::Mock08
219
+ eigenclass = class << self ; self ; end
220
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock08::Module1 ).should == true
221
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock08::Module2 ).should == true
222
+ end
223
+ module Proof2
224
+ include ModuleCluster::Define::ClusterCascades::Mock08::Proof1
225
+ eigenclass = class << self ; self ; end
226
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock08::Module1 ).should == true
227
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock08::Module2 ).should == true
228
+ end
229
+ end
230
+ end
231
+
232
+ ######################################################
233
+ # include_cascades_prepending_includes_and_extends #
234
+ ######################################################
235
+
236
+ it 'include and extend other modules for any class or module this module is included in, before this module is included' do
237
+ module ModuleCluster::Define::ClusterCascades::Mock09
238
+ extend ModuleCluster::Define::ClusterCascades
239
+ module Module1
240
+ end
241
+ module Module2
242
+ end
243
+ include_cascades_prepending_includes_and_extends( Module1, Module2 )
244
+ respond_to?( :append_features ).should == true
245
+ module Proof1
246
+ include ModuleCluster::Define::ClusterCascades::Mock09
247
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module1 ).should == true
248
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module2 ).should == true
249
+ eigenclass = class << self ; self ; end
250
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module1 ).should == true
251
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module2 ).should == true
252
+ end
253
+ module Proof2
254
+ include ModuleCluster::Define::ClusterCascades::Mock09::Proof1
255
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module1 ).should == true
256
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module2 ).should == true
257
+ eigenclass = class << self ; self ; end
258
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module1 ).should == true
259
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock09::Module2 ).should == true
260
+ end
261
+ end
262
+ end
263
+
264
+ #########################################
265
+ # extend_cascades_prepending_includes #
266
+ #########################################
267
+
268
+ it 'include other modules for any class or module this module is included in, before this module is extended' do
269
+ module ModuleCluster::Define::ClusterCascades::Mock10
270
+ extend ModuleCluster::Define::ClusterCascades
271
+ module Module1
272
+ end
273
+ module Module2
274
+ end
275
+ extend_cascades_prepending_includes( Module1, Module2 )
276
+ respond_to?( :extend_object ).should == true
277
+ module Proof1
278
+ extend ModuleCluster::Define::ClusterCascades::Mock10
279
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock10::Module1 ).should == true
280
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock10::Module2 ).should == true
281
+ end
282
+ module Proof2
283
+ extend ModuleCluster::Define::ClusterCascades::Mock10::Proof1
284
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock10::Module1 ).should == true
285
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock10::Module2 ).should == true
286
+ end
287
+ end
288
+ end
289
+
290
+ ########################################
291
+ # extend_cascades_prepending_extends #
292
+ ########################################
293
+
294
+ it 'extend other modules for any class or module this module is included in, before this module is extended' do
295
+ module ModuleCluster::Define::ClusterCascades::Mock11
296
+ extend ModuleCluster::Define::ClusterCascades
297
+ module Module1
298
+ end
299
+ module Module2
300
+ end
301
+ extend_cascades_prepending_extends( Module1, Module2 )
302
+ respond_to?( :extend_object ).should == true
303
+ module Proof1
304
+ extend ModuleCluster::Define::ClusterCascades::Mock11
305
+ eigenclass = class << self ; self ; end
306
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock11::Module1 ).should == true
307
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock11::Module2 ).should == true
308
+ end
309
+ module Proof2
310
+ extend ModuleCluster::Define::ClusterCascades::Mock11::Proof1
311
+ eigenclass = class << self ; self ; end
312
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock11::Module1 ).should == true
313
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock11::Module2 ).should == true
314
+ end
315
+ end
316
+ end
317
+
318
+ #####################################################
319
+ # extend_cascades_prepending_includes_and_extends #
320
+ #####################################################
321
+
322
+ it 'include and extend other modules for any class or module this module is included in, before this module is extended' do
323
+ module ModuleCluster::Define::ClusterCascades::Mock12
324
+ extend ModuleCluster::Define::ClusterCascades
325
+ module Module1
326
+ end
327
+ module Module2
328
+ end
329
+ extend_cascades_prepending_includes_and_extends( Module1, Module2 )
330
+ respond_to?( :extend_object ).should == true
331
+ module Proof1
332
+ extend ModuleCluster::Define::ClusterCascades::Mock12
333
+ end
334
+ module Proof2
335
+ extend ModuleCluster::Define::ClusterCascades::Mock12::Proof1
336
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock12::Module1 ).should == true
337
+ ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock12::Module2 ).should == true
338
+ eigenclass = class << self ; self ; end
339
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock12::Module1 ).should == true
340
+ eigenclass.ancestors.include?( ModuleCluster::Define::ClusterCascades::Mock12::Module2 ).should == true
341
+ end
342
+ end
343
+ end
344
+
345
+ end