module-cluster 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. data/README.md +54 -156
  2. data/README.rdoc +54 -130
  3. data/lib/module-cluster.rb +20 -16
  4. data/lib/module-cluster/ModuleCluster.rb +4 -120
  5. data/lib/module-cluster/ModuleCluster/Define/Deprecated.rb +40 -0
  6. data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +140 -0
  7. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascades.rb +140 -0
  8. data/lib/module-cluster/ModuleCluster/Define/ModuleClusterCascadesToClass.rb +140 -0
  9. data/lib/module-cluster/ModuleCluster/Define/_private_/ClusterStack.rb +28 -0
  10. data/lib/module-cluster/ModuleCluster/Define/_private_/ModuleCluster.rb +110 -0
  11. data/lib/module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascades.rb +118 -0
  12. data/lib/module-cluster/ModuleCluster/Define/_private_/ModuleClusterCascadesToClass.rb +126 -0
  13. data/spec/ModuleCluster/Define/ModuleClusterCascadesToClass_spec.rb +421 -0
  14. data/spec/ModuleCluster/Define/ModuleClusterCascades_spec.rb +345 -0
  15. data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +275 -0
  16. data/spec/ModuleCluster/Define/_private_/ClusterStack_spec.rb +24 -0
  17. data/spec/ModuleCluster/Define/_private_/ModuleClusterCascadesToClass_spec.rb +249 -0
  18. data/spec/ModuleCluster/Define/_private_/ModuleClusterCascades_spec.rb +223 -0
  19. data/spec/ModuleCluster/Define/_private_/ModuleCluster_spec.rb +168 -0
  20. data/spec/ModuleCluster_spec.rb +7 -2549
  21. metadata +21 -12
  22. data/lib/module-cluster/ModuleCluster/ExtendSupport.rb +0 -95
  23. data/lib/module-cluster/ModuleCluster/IncludeExtendSupport.rb +0 -104
  24. data/lib/module-cluster/ModuleCluster/IncludeSupport.rb +0 -94
  25. data/lib/module-cluster/ModuleCluster/_private_/IncludeExtendSupport.rb +0 -56
  26. data/lib/module-cluster/_private_/ModuleCluster.rb +0 -23
  27. data/spec/ModuleCluster/IncludeExtendSupport_spec.rb +0 -46
@@ -0,0 +1,275 @@
1
+
2
+ require_relative '../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::ModuleCluster do
5
+
6
+ ###########################
7
+ # include_also_includes #
8
+ ###########################
9
+
10
+ it 'include other modules when this one is included' do
11
+ module ModuleCluster::Define::ModuleCluster::Mock01
12
+ extend ModuleCluster::Define::ModuleCluster
13
+ module Module1
14
+ end
15
+ module Module2
16
+ end
17
+ include_also_includes( Module1, Module2 )
18
+ respond_to?( :included ).should == true
19
+ module Proof
20
+ include ModuleCluster::Define::ModuleCluster::Mock01
21
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock01::Module1 ).should == true
22
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock01::Module2 ).should == true
23
+ end
24
+ end
25
+ end
26
+
27
+ ##########################
28
+ # include_also_extends #
29
+ ##########################
30
+
31
+ it 'extend other modules when this one is included' do
32
+ module ModuleCluster::Define::ModuleCluster::Mock02
33
+ extend ModuleCluster::Define::ModuleCluster
34
+ module Module1
35
+ end
36
+ module Module2
37
+ end
38
+ include_also_extends( Module1, Module2 )
39
+ respond_to?( :included ).should == true
40
+ module Proof
41
+ include ModuleCluster::Define::ModuleCluster::Mock02
42
+ eigenclass = class << self ; self ; end
43
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock02::Module1 ).should == true
44
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock02::Module2 ).should == true
45
+ end
46
+ end
47
+ end
48
+
49
+ #######################################
50
+ # include_also_includes_and_extends #
51
+ #######################################
52
+
53
+ it 'include and extend other modules when this one is included' do
54
+ module ModuleCluster::Define::ModuleCluster::Mock03
55
+ extend ModuleCluster::Define::ModuleCluster
56
+ module Module1
57
+ end
58
+ module Module2
59
+ end
60
+ include_also_includes_and_extends( Module1, Module2 )
61
+ respond_to?( :included ).should == true
62
+ module Proof
63
+ include ModuleCluster::Define::ModuleCluster::Mock03
64
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock03::Module1 ).should == true
65
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock03::Module2 ).should == true
66
+ eigenclass = class << self ; self ; end
67
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock03::Module1 ).should == true
68
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock03::Module2 ).should == true
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ ##########################
75
+ # extend_also_includes #
76
+ ##########################
77
+
78
+ it 'include other modules when this one is extended' do
79
+ module ModuleCluster::Define::ModuleCluster::Mock04
80
+ extend ModuleCluster::Define::ModuleCluster
81
+ module Module1
82
+ end
83
+ module Module2
84
+ end
85
+ extend_also_includes( Module1, Module2 )
86
+ respond_to?( :extended ).should == true
87
+ module Proof
88
+ extend ModuleCluster::Define::ModuleCluster::Mock04
89
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock04::Module1 ).should == true
90
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock04::Module2 ).should == true
91
+ end
92
+ end
93
+ end
94
+
95
+ #########################
96
+ # extend_also_extends #
97
+ #########################
98
+
99
+ it 'extend other modules when this one is extended' do
100
+ module ModuleCluster::Define::ModuleCluster::Mock05
101
+ extend ModuleCluster::Define::ModuleCluster
102
+ module Module1
103
+ end
104
+ module Module2
105
+ end
106
+ extend_also_extends( Module1, Module2 )
107
+ respond_to?( :extended ).should == true
108
+ module Proof
109
+ extend ModuleCluster::Define::ModuleCluster::Mock05
110
+ eigenclass = class << self ; self ; end
111
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock05::Module1 ).should == true
112
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock05::Module2 ).should == true
113
+ end
114
+ end
115
+ end
116
+
117
+ ######################################
118
+ # extend_also_includes_and_extends #
119
+ ######################################
120
+
121
+ it 'include and extend other modules when this one is extended' do
122
+ module ModuleCluster::Define::ModuleCluster::Mock06
123
+ extend ModuleCluster::Define::ModuleCluster
124
+ module Module1
125
+ end
126
+ module Module2
127
+ end
128
+ extend_also_includes_and_extends( Module1, Module2 )
129
+ respond_to?( :extended ).should == true
130
+ module Proof
131
+ extend ModuleCluster::Define::ModuleCluster::Mock06
132
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock06::Module1 ).should == true
133
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock06::Module2 ).should == true
134
+ eigenclass = class << self ; self ; end
135
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock06::Module1 ).should == true
136
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock06::Module2 ).should == true
137
+ end
138
+ end
139
+ end
140
+
141
+ ###############################
142
+ # include_prepends_includes #
143
+ ###############################
144
+
145
+ it 'include other modules before this one is included' do
146
+ module ModuleCluster::Define::ModuleCluster::Mock07
147
+ extend ModuleCluster::Define::ModuleCluster
148
+ module Module1
149
+ end
150
+ module Module2
151
+ end
152
+ include_prepends_includes( Module1, Module2 )
153
+ respond_to?( :append_features ).should == true
154
+ module Proof
155
+ include ModuleCluster::Define::ModuleCluster::Mock07
156
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock07::Module1 ).should == true
157
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock07::Module2 ).should == true
158
+ end
159
+ end
160
+ end
161
+
162
+ ##############################
163
+ # include_prepends_extends #
164
+ ##############################
165
+
166
+ it 'extend other modules before this one is included' do
167
+ module ModuleCluster::Define::ModuleCluster::Mock08
168
+ extend ModuleCluster::Define::ModuleCluster
169
+ module Module1
170
+ end
171
+ module Module2
172
+ end
173
+ include_prepends_extends( Module1, Module2 )
174
+ respond_to?( :append_features ).should == true
175
+ module Proof
176
+ include ModuleCluster::Define::ModuleCluster::Mock08
177
+ eigenclass = class << self ; self ; end
178
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock08::Module1 ).should == true
179
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock08::Module2 ).should == true
180
+ end
181
+ end
182
+ end
183
+
184
+ ###########################################
185
+ # include_prepends_includes_and_extends #
186
+ ###########################################
187
+
188
+ it 'include and extend other modules before this one is included' do
189
+ module ModuleCluster::Define::ModuleCluster::Mock09
190
+ extend ModuleCluster::Define::ModuleCluster
191
+ module Module1
192
+ end
193
+ module Module2
194
+ end
195
+ include_prepends_includes_and_extends( Module1, Module2 )
196
+ respond_to?( :append_features ).should == true
197
+ module Proof
198
+ include ModuleCluster::Define::ModuleCluster::Mock09
199
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock09::Module1 ).should == true
200
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock09::Module2 ).should == true
201
+ eigenclass = class << self ; self ; end
202
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock09::Module1 ).should == true
203
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock09::Module2 ).should == true
204
+ end
205
+ end
206
+ end
207
+
208
+ ##############################
209
+ # extend_prepends_includes #
210
+ ##############################
211
+
212
+ it 'include other modules before this one is extended' do
213
+ module ModuleCluster::Define::ModuleCluster::Mock10
214
+ extend ModuleCluster::Define::ModuleCluster
215
+ module Module1
216
+ end
217
+ module Module2
218
+ end
219
+ extend_prepends_includes( Module1, Module2 )
220
+ respond_to?( :extend_object ).should == true
221
+ module Proof
222
+ extend ModuleCluster::Define::ModuleCluster::Mock10
223
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock10::Module1 ).should == true
224
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock10::Module2 ).should == true
225
+ end
226
+ end
227
+ end
228
+
229
+ #############################
230
+ # extend_prepends_extends #
231
+ #############################
232
+
233
+ it 'extend other modules before this one is extended' do
234
+ module ModuleCluster::Define::ModuleCluster::Mock11
235
+ extend ModuleCluster::Define::ModuleCluster
236
+ module Module1
237
+ end
238
+ module Module2
239
+ end
240
+ extend_prepends_extends( Module1, Module2 )
241
+ respond_to?( :extend_object ).should == true
242
+ module Proof
243
+ extend ModuleCluster::Define::ModuleCluster::Mock11
244
+ eigenclass = class << self ; self ; end
245
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock11::Module1 ).should == true
246
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock11::Module2 ).should == true
247
+ end
248
+ end
249
+ end
250
+
251
+ ##########################################
252
+ # extend_prepends_includes_and_extends #
253
+ ##########################################
254
+
255
+ it 'include and extend other modules before this one is extended' do
256
+ module ModuleCluster::Define::ModuleCluster::Mock12
257
+ extend ModuleCluster::Define::ModuleCluster
258
+ module Module1
259
+ end
260
+ module Module2
261
+ end
262
+ extend_prepends_includes_and_extends( Module1, Module2 )
263
+ respond_to?( :extend_object ).should == true
264
+ module Proof
265
+ extend ModuleCluster::Define::ModuleCluster::Mock12
266
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock12::Module1 ).should == true
267
+ ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock12::Module2 ).should == true
268
+ eigenclass = class << self ; self ; end
269
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock12::Module1 ).should == true
270
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleCluster::Mock12::Module2 ).should == true
271
+ end
272
+ end
273
+ end
274
+
275
+ end
@@ -0,0 +1,24 @@
1
+
2
+ require_relative '../../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::ClusterStack do
5
+
6
+ #########################
7
+ # clusterstack_module #
8
+ #########################
9
+
10
+ it 'constructs an anonymous module to stack the included/extended/append_features/extend_object chain' do
11
+
12
+ class ModuleCluster::Define::ClusterStack::Mock
13
+ extend ModuleCluster::Define::ClusterStack
14
+ # get instance of module
15
+ clusterstack_module_instance = clusterstack_module
16
+ # make sure it's a module
17
+ clusterstack_module_instance.is_a?( Module ).should == true
18
+ # make sure we get the same one after the first time
19
+ clusterstack_module.should == clusterstack_module_instance
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,249 @@
1
+
2
+ require_relative '../../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Define::ModuleClusterCascadesToClass do
5
+
6
+ #######################################################
7
+ # anonymous_module_cascade_to_class_append_features #
8
+ #######################################################
9
+
10
+ it 'it can construct an anonymous module each time requested to append features with modules' do
11
+ class ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01
12
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass
13
+ module Module1
14
+ end
15
+ module Module2
16
+ end
17
+ anonymous_module_cascade_to_class_append_features_instance = anonymous_module_cascade_to_class_append_features( :include, Module1, Module2 )
18
+ anonymous_module_cascade_to_class_append_features_instance.is_a?( Module ).should == true
19
+ anonymous_module_cascade_to_class_append_features_instance.instance_methods.include?( :append_features ).should == true
20
+ module SomeModule
21
+ end
22
+ SomeModule.extend( anonymous_module_cascade_to_class_append_features_instance )
23
+ SomeModule.respond_to?( :append_features ).should == true
24
+ module SomeOtherModule
25
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::SomeModule
26
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ).should == false
27
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ).should == false
28
+ end
29
+ module Cascade1
30
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::SomeOtherModule
31
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ).should == false
32
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ).should == false
33
+ end
34
+ class CascadeClass1
35
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Cascade1
36
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ).should == true
37
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ).should == true
38
+ ( ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ) > ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ) ).should == true
39
+ ( ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ) > ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::SomeModule ) ).should == true
40
+ ( ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::SomeModule ) > ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::SomeOtherModule ) ).should == true
41
+ end
42
+ anonymous_module_cascade_to_class_append_features_instance2 = anonymous_module_cascade_to_class_append_features( :extend, Module1, Module2 )
43
+ anonymous_module_cascade_to_class_append_features_instance2.should_not == anonymous_module_cascade_to_class_append_features_instance
44
+ module AnotherModule
45
+ end
46
+ AnotherModule.extend( anonymous_module_cascade_to_class_append_features_instance2 )
47
+ AnotherModule.respond_to?( :append_features ).should == true
48
+ module YetAnotherModule
49
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::AnotherModule
50
+ eigenclass = class << self ; self ; end
51
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ).should == false
52
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ).should == false
53
+ end
54
+ module Cascade2
55
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::YetAnotherModule
56
+ eigenclass = class << self ; self ; end
57
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ).should == false
58
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ).should == false
59
+ end
60
+ class CascadeClass2
61
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Cascade2
62
+ eigenclass = class << self ; self ; end
63
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ).should == true
64
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ).should == true
65
+ ( eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module1 ) > eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock01::Module2 ) ).should == true
66
+ end
67
+ end
68
+ end
69
+
70
+ ################################################
71
+ # anonymous_module_cascade_to_class_included #
72
+ ################################################
73
+
74
+ it 'it can construct an anonymous module each time requested to include with modules' do
75
+ class ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02
76
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass
77
+ module Module1
78
+ end
79
+ module Module2
80
+ end
81
+ anonymous_module_cascade_to_class_included_instance = anonymous_module_cascade_to_class_included( :include, Module1, Module2 )
82
+ anonymous_module_cascade_to_class_included_instance.is_a?( Module ).should == true
83
+ anonymous_module_cascade_to_class_included_instance.instance_methods.include?( :included ).should == true
84
+ module SomeModule
85
+ end
86
+ SomeModule.extend( anonymous_module_cascade_to_class_included_instance )
87
+ SomeModule.respond_to?( :included ).should == true
88
+ module SomeOtherModule
89
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::SomeModule
90
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module1 ).should == false
91
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module2 ).should == false
92
+ end
93
+ module Cascade1
94
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::SomeOtherModule
95
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module1 ).should == false
96
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module2 ).should == false
97
+ end
98
+ class CascadeClass1
99
+ end
100
+ anonymous_module_cascade_to_class_included_instance2 = anonymous_module_cascade_to_class_included( :extend, Module1, Module2 )
101
+ anonymous_module_cascade_to_class_included_instance2.should_not == anonymous_module_cascade_to_class_included_instance
102
+ module AnotherModule
103
+ end
104
+ AnotherModule.extend( anonymous_module_cascade_to_class_included_instance2 )
105
+ AnotherModule.respond_to?( :included ).should == true
106
+ module YetAnotherModule
107
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::AnotherModule
108
+ eigenclass = class << self ; self ; end
109
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module1 ).should == false
110
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module2 ).should == false
111
+ end
112
+ module Cascade2
113
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::YetAnotherModule
114
+ eigenclass = class << self ; self ; end
115
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module1 ).should == false
116
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module2 ).should == false
117
+ end
118
+ class CascadeClass2
119
+ include ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Cascade2
120
+ eigenclass = class << self ; self ; end
121
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module1 ).should == true
122
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module2 ).should == true
123
+ ( eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module1 ) > eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock02::Module2 ) ).should == true
124
+ end
125
+ end
126
+ end
127
+
128
+ #####################################################
129
+ # anonymous_module_cascade_to_class_extend_object #
130
+ #####################################################
131
+
132
+ it 'it can construct an anonymous module each time requested to extend object with modules' do
133
+ class ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03
134
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass
135
+ module Module1
136
+ end
137
+ module Module2
138
+ end
139
+ anonymous_module_cascade_to_class_extend_object_instance = anonymous_module_cascade_to_class_extend_object( :include, Module1, Module2 )
140
+ anonymous_module_cascade_to_class_extend_object_instance.is_a?( Module ).should == true
141
+ anonymous_module_cascade_to_class_extend_object_instance.instance_methods.include?( :extend_object ).should == true
142
+ module SomeModule
143
+ end
144
+ SomeModule.extend( anonymous_module_cascade_to_class_extend_object_instance )
145
+ SomeModule.respond_to?( :extend_object ).should == true
146
+ module SomeOtherModule
147
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::SomeModule
148
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module1 ).should == false
149
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module2 ).should == false
150
+ end
151
+ module Cascade1
152
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::SomeOtherModule
153
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module1 ).should == false
154
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module2 ).should == false
155
+ end
156
+ class CascadeClass1
157
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Cascade1
158
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module1 ).should == true
159
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module2 ).should == true
160
+ ( ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module1 ) > ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module2 ) ).should == true
161
+ end
162
+ anonymous_module_cascade_to_class_extend_object_instance2 = anonymous_module_cascade_to_class_extend_object( :extend, Module1, Module2 )
163
+ anonymous_module_cascade_to_class_extend_object_instance2.should_not == anonymous_module_cascade_to_class_extend_object_instance
164
+ module AnotherModule
165
+ end
166
+ AnotherModule.extend( anonymous_module_cascade_to_class_extend_object_instance2 )
167
+ AnotherModule.respond_to?( :extend_object ).should == true
168
+ module YetAnotherModule
169
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::AnotherModule
170
+ eigenclass = class << self ; self ; end
171
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module1 ).should == false
172
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module2 ).should == false
173
+ end
174
+ module Cascade2
175
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::YetAnotherModule
176
+ end
177
+ class CascadeClass2
178
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Cascade2
179
+ eigenclass = class << self ; self ; end
180
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module1 ).should == true
181
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module2 ).should == true
182
+ ( eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module1 ) > eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock03::Module2 ) ).should == true
183
+ end
184
+ end
185
+ end
186
+
187
+ ################################################
188
+ # anonymous_module_cascade_to_class_extended #
189
+ ################################################
190
+
191
+ it 'it can construct an anonymous module each time requested to extend with modules' do
192
+ class ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04
193
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass
194
+ module Module1
195
+ end
196
+ module Module2
197
+ end
198
+ anonymous_module_cascade_to_class_extended_instance = anonymous_module_cascade_to_class_extended( :include, Module1, Module2 )
199
+ anonymous_module_cascade_to_class_extended_instance.is_a?( Module ).should == true
200
+ anonymous_module_cascade_to_class_extended_instance.instance_methods.include?( :extended ).should == true
201
+ module SomeModule
202
+ end
203
+ SomeModule.extend( anonymous_module_cascade_to_class_extended_instance )
204
+ SomeModule.respond_to?( :extended ).should == true
205
+ module SomeOtherModule
206
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::SomeModule
207
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ).should == false
208
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ).should == false
209
+ end
210
+ module Cascade1
211
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::SomeOtherModule
212
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ).should == false
213
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ).should == false
214
+ end
215
+ class CascadeClass1
216
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Cascade1
217
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ).should == true
218
+ ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ).should == true
219
+ ( ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ) > ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ) ).should == true
220
+ end
221
+ anonymous_module_cascade_to_class_extended_instance2 = anonymous_module_cascade_to_class_extended( :extend, Module1, Module2 )
222
+ anonymous_module_cascade_to_class_extended_instance2.should_not == anonymous_module_cascade_to_class_extended_instance
223
+ module AnotherModule
224
+ end
225
+ AnotherModule.extend( anonymous_module_cascade_to_class_extended_instance2 )
226
+ AnotherModule.respond_to?( :extended ).should == true
227
+ module YetAnotherModule
228
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::AnotherModule
229
+ eigenclass = class << self ; self ; end
230
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ).should == false
231
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ).should == false
232
+ end
233
+ module Cascade2
234
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::YetAnotherModule
235
+ eigenclass = class << self ; self ; end
236
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ).should == false
237
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ).should == false
238
+ end
239
+ class CascadeClass2
240
+ extend ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Cascade2
241
+ eigenclass = class << self ; self ; end
242
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ).should == true
243
+ eigenclass.ancestors.include?( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ).should == true
244
+ ( eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module1 ) > eigenclass.ancestors.index( ModuleCluster::Define::ModuleClusterCascadesToClass::PrivateMock04::Module2 ) ).should == true
245
+ end
246
+ end
247
+ end
248
+
249
+ end