module-cluster 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,126 @@
1
+
2
+ module ModuleCluster::Define::ModuleClusterCascadesToModule
3
+
4
+ ###########################################################################################################
5
+ private ###############################################################################################
6
+ ###########################################################################################################
7
+
8
+ include ModuleCluster::Define::ClusterStack
9
+
10
+ ########################################################
11
+ # anonymous_module_cascade_to_module_append_features #
12
+ ########################################################
13
+
14
+ def anonymous_module_cascade_to_module_append_features( extend_or_include, *other_modules )
15
+
16
+ return Module.new do
17
+
18
+ #-------------------#
19
+ # append_features #
20
+ #-------------------#
21
+
22
+ define_method( :append_features ) do |class_or_module|
23
+ class_or_module.module_eval do
24
+ unless is_a?( Class )
25
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
26
+ extend( anonymous_module_cascade_to_module_append_features( extend_or_include, *other_modules ) )
27
+ other_modules.each do |this_module|
28
+ __send__( extend_or_include, this_module )
29
+ end
30
+ end
31
+ end
32
+ super( class_or_module )
33
+ end
34
+
35
+ end
36
+
37
+ end
38
+
39
+ #################################################
40
+ # anonymous_module_cascade_to_module_included #
41
+ #################################################
42
+
43
+ def anonymous_module_cascade_to_module_included( extend_or_include, *other_modules )
44
+
45
+ return Module.new do
46
+
47
+ #------------#
48
+ # included #
49
+ #------------#
50
+
51
+ define_method( :included ) do |class_or_module|
52
+ super( class_or_module )
53
+ class_or_module.module_eval do
54
+ unless is_a?( Class )
55
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
56
+ extend( anonymous_module_cascade_to_module_included( extend_or_include, *other_modules ) )
57
+ other_modules.each do |this_module|
58
+ __send__( extend_or_include, this_module )
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+
68
+ ######################################################
69
+ # anonymous_module_cascade_to_module_extend_object #
70
+ ######################################################
71
+
72
+ def anonymous_module_cascade_to_module_extend_object( extend_or_include, *other_modules )
73
+
74
+ return Module.new do
75
+
76
+ #-----------------#
77
+ # extend_object #
78
+ #-----------------#
79
+
80
+ define_method( :extend_object ) do |class_or_module|
81
+ class_or_module.module_eval do
82
+ unless is_a?( Class )
83
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
84
+ extend( anonymous_module_cascade_to_module_extend_object( extend_or_include, *other_modules ) )
85
+ other_modules.each do |this_module|
86
+ __send__( extend_or_include, this_module )
87
+ end
88
+ end
89
+ end
90
+ super( class_or_module )
91
+ end
92
+
93
+ end
94
+
95
+ end
96
+
97
+ #################################################
98
+ # anonymous_module_cascade_to_module_extended #
99
+ #################################################
100
+
101
+ def anonymous_module_cascade_to_module_extended( extend_or_include, *other_modules )
102
+
103
+ return Module.new do
104
+
105
+ #------------#
106
+ # included #
107
+ #------------#
108
+
109
+ define_method( :extended ) do |class_or_module|
110
+ super( class_or_module )
111
+ class_or_module.module_eval do
112
+ unless is_a?( Class )
113
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
114
+ extend( anonymous_module_cascade_to_module_extended( extend_or_include, *other_modules ) )
115
+ other_modules.each do |this_module|
116
+ __send__( extend_or_include, this_module )
117
+ end
118
+ end
119
+ end
120
+ end
121
+
122
+ end
123
+
124
+ end
125
+
126
+ end
@@ -0,0 +1,432 @@
1
+
2
+ require_relative '../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::ModuleClusterCascadesToModule 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::ModuleClusterCascadesToModule::Mock01
12
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock01
21
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock01::Module1 ).should == true
22
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock01::Module2 ).should == true
23
+ end
24
+ module Proof2
25
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock01::Proof1
26
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock01::Module1 ).should == true
27
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock01::Module2 ).should == true
28
+ end
29
+ class Proof3
30
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock01::Proof2
31
+ # true b/c of ancestor chain
32
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock01::Module1 ).should == true
33
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock02
44
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock02
53
+ eigenclass = class << self ; self ; end
54
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock02::Module1 ).should == true
55
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock02::Module2 ).should == true
56
+ end
57
+ module Proof2
58
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock02::Proof1
59
+ eigenclass = class << self ; self ; end
60
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock02::Module1 ).should == true
61
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock02::Module2 ).should == true
62
+ end
63
+ class Proof3
64
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock02::Proof2
65
+ eigenclass = class << self ; self ; end
66
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock02::Module1 ).should == false
67
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock03
78
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock03
87
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module1 ).should == true
88
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module2 ).should == true
89
+ eigenclass = class << self ; self ; end
90
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module1 ).should == true
91
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module2 ).should == true
92
+ end
93
+ module Proof2
94
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Proof1
95
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module1 ).should == true
96
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module2 ).should == true
97
+ eigenclass = class << self ; self ; end
98
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module1 ).should == true
99
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module2 ).should == true
100
+ end
101
+ class Proof3
102
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Proof2
103
+ # true b/c of ancestor chain
104
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module1 ).should == true
105
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module2 ).should == true
106
+ eigenclass = class << self ; self ; end
107
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock03::Module1 ).should == false
108
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock04
119
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock04
128
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock04::Module1 ).should == true
129
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock04::Module2 ).should == true
130
+ end
131
+ module Proof2
132
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock04::Proof1
133
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock04::Module1 ).should == true
134
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock04::Module2 ).should == true
135
+ end
136
+ class Proof3
137
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock04::Proof2
138
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock04::Module1 ).should == false
139
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock05
150
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock05
159
+ eigenclass = class << self ; self ; end
160
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock05::Module1 ).should == true
161
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock05::Module2 ).should == true
162
+ end
163
+ module Proof2
164
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock05::Proof1
165
+ eigenclass = class << self ; self ; end
166
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock05::Module1 ).should == true
167
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock05::Module2 ).should == true
168
+ end
169
+ class Proof3
170
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock05::Proof2
171
+ eigenclass = class << self ; self ; end
172
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock05::Module1 ).should == false
173
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock06
184
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock06
193
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module1 ).should == true
194
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module2 ).should == true
195
+ eigenclass = class << self ; self ; end
196
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module1 ).should == true
197
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module2 ).should == true
198
+ end
199
+ module Proof2
200
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Proof1
201
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module1 ).should == true
202
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module2 ).should == true
203
+ eigenclass = class << self ; self ; end
204
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module1 ).should == true
205
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module2 ).should == true
206
+ end
207
+ class Proof3
208
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Proof2
209
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module1 ).should == false
210
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module2 ).should == false
211
+ eigenclass = class << self ; self ; end
212
+ # true because Proof2's ancestor chain includes
213
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock06::Module1 ).should == true
214
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock07
225
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock07
234
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock07::Module1 ).should == true
235
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock07::Module2 ).should == true
236
+ end
237
+ module Proof2
238
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock07::Proof1
239
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock07::Module1 ).should == true
240
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock07::Module2 ).should == true
241
+ end
242
+ class Proof3
243
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock07::Proof2
244
+ # true b/c of ancestor chain
245
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock07::Module1 ).should == true
246
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock08
257
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock08
266
+ eigenclass = class << self ; self ; end
267
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock08::Module1 ).should == true
268
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock08::Module2 ).should == true
269
+ end
270
+ module Proof2
271
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock08::Proof1
272
+ eigenclass = class << self ; self ; end
273
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock08::Module1 ).should == true
274
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock08::Module2 ).should == true
275
+ end
276
+ class Proof3
277
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock08::Proof2
278
+ eigenclass = class << self ; self ; end
279
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock08::Module1 ).should == false
280
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock09
291
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock09
300
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module1 ).should == true
301
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module2 ).should == true
302
+ eigenclass = class << self ; self ; end
303
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module1 ).should == true
304
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module2 ).should == true
305
+ end
306
+ module Proof2
307
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Proof1
308
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module1 ).should == true
309
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module2 ).should == true
310
+ eigenclass = class << self ; self ; end
311
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module1 ).should == true
312
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module2 ).should == true
313
+ end
314
+ class Proof3
315
+ include ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Proof2
316
+ # true b/c of ancestor chain
317
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module1 ).should == true
318
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module2 ).should == true
319
+ eigenclass = class << self ; self ; end
320
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock09::Module1 ).should == false
321
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock10
332
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock10
341
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock10::Module1 ).should == true
342
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock10::Module2 ).should == true
343
+ end
344
+ module Proof2
345
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock10::Proof1
346
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock10::Module1 ).should == true
347
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock10::Module2 ).should == true
348
+ end
349
+ class Proof3
350
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock10::Proof2
351
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock10::Module1 ).should == false
352
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock11
363
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock11
372
+ eigenclass = class << self ; self ; end
373
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock11::Module1 ).should == true
374
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock11::Module2 ).should == true
375
+ end
376
+ module Proof2
377
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock11::Proof1
378
+ eigenclass = class << self ; self ; end
379
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock11::Module1 ).should == true
380
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock11::Module2 ).should == true
381
+ end
382
+ class Proof3
383
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock11::Proof2
384
+ eigenclass = class << self ; self ; end
385
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock11::Module1 ).should == false
386
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::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::ModuleClusterCascadesToModule::Mock12
397
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule
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::ModuleClusterCascadesToModule::Mock12
406
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module1 ).should == true
407
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module2 ).should == true
408
+ eigenclass = class << self ; self ; end
409
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module1 ).should == true
410
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module2 ).should == true
411
+ end
412
+ module Proof2
413
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Proof1
414
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module1 ).should == true
415
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module2 ).should == true
416
+ eigenclass = class << self ; self ; end
417
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module1 ).should == true
418
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module2 ).should == true
419
+ end
420
+ class Proof3
421
+ extend ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Proof2
422
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module1 ).should == false
423
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module2 ).should == false
424
+ eigenclass = class << self ; self ; end
425
+ # true b/c Proof2's ancestors include
426
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module1 ).should == true
427
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToModule::Mock12::Module2 ).should == true
428
+ end
429
+ end
430
+ end
431
+
432
+ end