module-cluster 1.3.7 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +146 -1
- data/README.rdoc +146 -1
- data/lib/module-cluster.rb +54 -12
- data/lib/module-cluster/ModuleCluster/Define/Block.rb +3 -0
- data/lib/module-cluster/ModuleCluster/Define/Block/Class.rb +16 -4
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrInstance.rb +63 -0
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModule.rb +2 -0
- data/lib/module-cluster/ModuleCluster/Define/Block/ClassOrModuleOrInstance.rb +63 -0
- data/lib/module-cluster/ModuleCluster/Define/Block/Instance.rb +32 -0
- data/lib/module-cluster/ModuleCluster/Define/Block/Module.rb +16 -4
- data/lib/module-cluster/ModuleCluster/Define/Block/ModuleOrInstance.rb +63 -0
- data/lib/module-cluster/ModuleCluster/Define/ClassCluster.rb +200 -0
- data/lib/module-cluster/ModuleCluster/Define/ClassOrInstanceCluster.rb +127 -0
- data/lib/module-cluster/ModuleCluster/Define/Cluster.rb +7 -19
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascades.rb +5 -20
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToClass.rb +9 -26
- data/lib/module-cluster/ModuleCluster/Define/ClusterCascadesToModule.rb +9 -26
- data/lib/module-cluster/ModuleCluster/Define/InstanceCluster.rb +46 -0
- data/lib/module-cluster/ModuleCluster/Define/ModuleCluster.rb +200 -0
- data/lib/module-cluster/ModuleCluster/Define/ModuleOrClassCluster.rb +208 -0
- data/lib/module-cluster/ModuleCluster/Define/ModuleOrInstanceCluster.rb +127 -0
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures.rb +54 -0
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/ClusterStack.rb +44 -0
- data/lib/module-cluster/_private_/ModuleCluster/CascadeFeatures/PerformCascades.rb +209 -0
- data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack.rb +0 -2
- data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ClusterStack/Block.rb +1 -2
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Class.rb +36 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Instance.rb +20 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Module.rb +36 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Block/Set.rb +2 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Extends.rb +108 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Includes.rb +84 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsExtends.rb +108 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/PrependsIncludes.rb +84 -0
- data/lib/module-cluster/_private_/ModuleCluster/ClusterStack/Set.rb +7 -0
- data/lib/module-cluster/{ModuleCluster → _private_/ModuleCluster}/ExtendForCascade.rb +0 -0
- data/spec/ModuleCluster/Define/Block/ClassOrInstance_spec.rb +230 -0
- data/spec/ModuleCluster/Define/Block/ClassOrModuleOrInstance_spec.rb +238 -0
- data/spec/ModuleCluster/Define/Block/ClassOrModule_spec.rb +231 -0
- data/spec/ModuleCluster/Define/Block/Class_spec.rb +224 -0
- data/spec/ModuleCluster/Define/Block/Instance_spec.rb +78 -0
- data/spec/ModuleCluster/Define/Block/ModuleOrInstance_spec.rb +54 -0
- data/spec/ModuleCluster/Define/Block/Module_spec.rb +224 -0
- data/spec/ModuleCluster/Define/Block_spec.rb +18 -0
- data/spec/ModuleCluster/Define/ClassCluster_spec.rb +728 -0
- data/spec/ModuleCluster/Define/ClassOrInstanceCluster_spec.rb +576 -0
- data/spec/ModuleCluster/Define/ClusterCascadesToClass_spec.rb +298 -60
- data/spec/ModuleCluster/Define/ClusterCascadesToModule_spec.rb +307 -61
- data/spec/ModuleCluster/Define/ClusterCascades_spec.rb +335 -36
- data/spec/ModuleCluster/Define/Cluster_spec.rb +447 -14
- data/spec/ModuleCluster/Define/InstanceCluster_spec.rb +102 -0
- data/spec/ModuleCluster/Define/ModuleCluster_spec.rb +728 -0
- data/spec/ModuleCluster/Define/ModuleOrClassCluster_spec.rb +728 -0
- data/spec/ModuleCluster/Define/ModuleOrInstanceCluster_spec.rb +576 -0
- data/spec/_private_/ModuleCluster/CascadeFeatures/PerformCascades_spec.rb +278 -0
- metadata +42 -13
- data/lib/module-cluster/ModuleCluster/CascadeFeatures.rb +0 -197
- data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Class.rb +0 -36
- data/lib/module-cluster/ModuleCluster/ClusterStack/Block/Module.rb +0 -36
- data/lib/module-cluster/ModuleCluster/ClusterStack/Extends.rb +0 -29
- data/lib/module-cluster/ModuleCluster/ClusterStack/Includes.rb +0 -28
- data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsExtends.rb +0 -28
- data/lib/module-cluster/ModuleCluster/ClusterStack/PrependsIncludes.rb +0 -28
- data/lib/module-cluster/ModuleCluster/Define/ClusterStack.rb +0 -26
@@ -0,0 +1,238 @@
|
|
1
|
+
|
2
|
+
require_relative '../../../../lib/module-cluster.rb'
|
3
|
+
|
4
|
+
describe ModuleCluster::Define::Block::ClassOrModuleOrInstance do
|
5
|
+
|
6
|
+
########################################
|
7
|
+
# class_or_module_or_instance_extend #
|
8
|
+
########################################
|
9
|
+
|
10
|
+
it 'can run a block on class or module extend' do
|
11
|
+
module ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock01
|
12
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance
|
13
|
+
block_ran = false
|
14
|
+
class_or_module_or_instance_extend do
|
15
|
+
block_ran = true
|
16
|
+
self.should == ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock01
|
17
|
+
end
|
18
|
+
respond_to?( :extended ).should == true
|
19
|
+
module ModuleProof
|
20
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock01
|
21
|
+
end
|
22
|
+
block_ran.should == false
|
23
|
+
module ModuleProof2
|
24
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock01
|
25
|
+
end
|
26
|
+
block_ran.should == true
|
27
|
+
block_ran = false
|
28
|
+
class ClassProof
|
29
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock01
|
30
|
+
end
|
31
|
+
block_ran.should == false
|
32
|
+
class ClassProof2
|
33
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock01
|
34
|
+
end
|
35
|
+
block_ran.should == true
|
36
|
+
block_ran = false
|
37
|
+
Object.new.instance_eval do
|
38
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock01
|
39
|
+
end
|
40
|
+
block_ran.should == true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
################################################
|
45
|
+
# class_or_module_include_or_instance_extend #
|
46
|
+
################################################
|
47
|
+
|
48
|
+
it 'can run a block on class or module include or instance extend' do
|
49
|
+
module ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock02
|
50
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance
|
51
|
+
block_ran = false
|
52
|
+
class_or_module_include_or_instance_extend do
|
53
|
+
block_ran = true
|
54
|
+
self.should == ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock02
|
55
|
+
end
|
56
|
+
respond_to?( :extended ).should == true
|
57
|
+
module ModuleProof
|
58
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock02
|
59
|
+
end
|
60
|
+
block_ran.should == true
|
61
|
+
block_ran = false
|
62
|
+
module ModuleProof2
|
63
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock02
|
64
|
+
end
|
65
|
+
block_ran.should == false
|
66
|
+
class ClassProof
|
67
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock02
|
68
|
+
end
|
69
|
+
block_ran.should == true
|
70
|
+
block_ran = false
|
71
|
+
class ClassProof2
|
72
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock02
|
73
|
+
end
|
74
|
+
block_ran.should == false
|
75
|
+
Object.new.instance_eval do
|
76
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock02
|
77
|
+
end
|
78
|
+
block_ran.should == true
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
##########################################################
|
83
|
+
# class_or_module_include_or_extend_or_instance_extend #
|
84
|
+
##########################################################
|
85
|
+
|
86
|
+
it 'can run a block on class or module include or extend or instance extend' do
|
87
|
+
module ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock03
|
88
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance
|
89
|
+
block_ran = false
|
90
|
+
class_or_module_include_or_extend_or_instance_extend do
|
91
|
+
block_ran = true
|
92
|
+
self.should == ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock03
|
93
|
+
end
|
94
|
+
respond_to?( :extended ).should == true
|
95
|
+
module ModuleProof
|
96
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock03
|
97
|
+
end
|
98
|
+
block_ran.should == true
|
99
|
+
block_ran = false
|
100
|
+
module ModuleProof2
|
101
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock03
|
102
|
+
end
|
103
|
+
block_ran.should == true
|
104
|
+
block_ran = false
|
105
|
+
class ClassProof
|
106
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock03
|
107
|
+
end
|
108
|
+
block_ran.should == true
|
109
|
+
block_ran = false
|
110
|
+
class ClassProof2
|
111
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock03
|
112
|
+
end
|
113
|
+
block_ran.should == true
|
114
|
+
block_ran = false
|
115
|
+
Object.new.instance_eval do
|
116
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock03
|
117
|
+
end
|
118
|
+
block_ran.should == true
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
################################################
|
123
|
+
# prepend_class_or_module_or_instance_extend #
|
124
|
+
################################################
|
125
|
+
|
126
|
+
it 'can run a block before class or module extend' do
|
127
|
+
module ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock04
|
128
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance
|
129
|
+
block_ran = false
|
130
|
+
prepend_class_or_module_or_instance_extend do
|
131
|
+
block_ran = true
|
132
|
+
self.should == ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock04
|
133
|
+
end
|
134
|
+
respond_to?( :extended ).should == true
|
135
|
+
module ModuleProof
|
136
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock04
|
137
|
+
end
|
138
|
+
block_ran.should == false
|
139
|
+
module ModuleProof2
|
140
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock04
|
141
|
+
end
|
142
|
+
block_ran.should == true
|
143
|
+
block_ran = false
|
144
|
+
class ClassProof
|
145
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock04
|
146
|
+
end
|
147
|
+
block_ran.should == false
|
148
|
+
class ClassProof2
|
149
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock04
|
150
|
+
end
|
151
|
+
block_ran.should == true
|
152
|
+
block_ran = false
|
153
|
+
Object.new.instance_eval do
|
154
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock04
|
155
|
+
end
|
156
|
+
block_ran.should == true
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
########################################################
|
161
|
+
# prepend_class_or_module_include_or_instance_extend #
|
162
|
+
########################################################
|
163
|
+
|
164
|
+
it 'can run a block before class or module include or instance extend' do
|
165
|
+
module ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock05
|
166
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance
|
167
|
+
block_ran = false
|
168
|
+
prepend_class_or_module_include_or_instance_extend do
|
169
|
+
block_ran = true
|
170
|
+
self.should == ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock05
|
171
|
+
end
|
172
|
+
respond_to?( :extended ).should == true
|
173
|
+
module ModuleProof
|
174
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock05
|
175
|
+
end
|
176
|
+
block_ran.should == true
|
177
|
+
block_ran = false
|
178
|
+
module ModuleProof2
|
179
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock05
|
180
|
+
end
|
181
|
+
block_ran.should == false
|
182
|
+
class ClassProof
|
183
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock05
|
184
|
+
end
|
185
|
+
block_ran.should == true
|
186
|
+
block_ran = false
|
187
|
+
class ClassProof2
|
188
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock05
|
189
|
+
end
|
190
|
+
block_ran.should == false
|
191
|
+
Object.new.instance_eval do
|
192
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock05
|
193
|
+
end
|
194
|
+
block_ran.should == true
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
##################################################################
|
199
|
+
# prepend_class_or_module_include_or_extend_or_instance_extend #
|
200
|
+
##################################################################
|
201
|
+
|
202
|
+
it 'can run a block before class or module include or extend or instance extend' do
|
203
|
+
module ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock06
|
204
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance
|
205
|
+
block_ran = false
|
206
|
+
prepend_class_or_module_include_or_extend_or_instance_extend do
|
207
|
+
block_ran = true
|
208
|
+
self.should == ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock06
|
209
|
+
end
|
210
|
+
respond_to?( :extended ).should == true
|
211
|
+
module ModuleProof
|
212
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock06
|
213
|
+
end
|
214
|
+
block_ran.should == true
|
215
|
+
block_ran = false
|
216
|
+
module ModuleProof2
|
217
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock06
|
218
|
+
end
|
219
|
+
block_ran.should == true
|
220
|
+
block_ran = false
|
221
|
+
class ClassProof
|
222
|
+
include ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock06
|
223
|
+
end
|
224
|
+
block_ran.should == true
|
225
|
+
block_ran = false
|
226
|
+
class ClassProof2
|
227
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock06
|
228
|
+
end
|
229
|
+
block_ran.should == true
|
230
|
+
block_ran = false
|
231
|
+
Object.new.instance_eval do
|
232
|
+
extend ModuleCluster::Define::Block::ClassOrModuleOrInstance::Mock06
|
233
|
+
end
|
234
|
+
block_ran.should == true
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
|
2
|
+
require_relative '../../../../lib/module-cluster.rb'
|
3
|
+
|
4
|
+
describe ModuleCluster::Define::Block::ClassOrModule do
|
5
|
+
|
6
|
+
#############################
|
7
|
+
# class_or_module_include #
|
8
|
+
#############################
|
9
|
+
|
10
|
+
it 'can run a block on class or module include' do
|
11
|
+
module ModuleCluster::Define::Block::ClassOrModule::Mock01
|
12
|
+
extend ModuleCluster::Define::Block::ClassOrModule
|
13
|
+
block_ran = false
|
14
|
+
class_or_module_include do
|
15
|
+
block_ran = true
|
16
|
+
self.should == ModuleCluster::Define::Block::ClassOrModule::Mock01
|
17
|
+
end
|
18
|
+
respond_to?( :included ).should == true
|
19
|
+
class ClassProof
|
20
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock01
|
21
|
+
end
|
22
|
+
block_ran.should == false
|
23
|
+
class ClassProof2
|
24
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock01
|
25
|
+
end
|
26
|
+
block_ran.should == true
|
27
|
+
block_ran = false
|
28
|
+
Object.new.instance_eval do
|
29
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock01
|
30
|
+
end
|
31
|
+
block_ran.should == false
|
32
|
+
module ModuleProof
|
33
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock01
|
34
|
+
end
|
35
|
+
block_ran.should == false
|
36
|
+
module ModuleProof2
|
37
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock01
|
38
|
+
end
|
39
|
+
block_ran.should == true
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
############################
|
44
|
+
# class_or_module_extend #
|
45
|
+
############################
|
46
|
+
|
47
|
+
it 'can run a block on class or module extend' do
|
48
|
+
module ModuleCluster::Define::Block::ClassOrModule::Mock02
|
49
|
+
extend ModuleCluster::Define::Block::ClassOrModule
|
50
|
+
block_ran = false
|
51
|
+
class_or_module_extend do
|
52
|
+
block_ran = true
|
53
|
+
self.should == ModuleCluster::Define::Block::ClassOrModule::Mock02
|
54
|
+
end
|
55
|
+
respond_to?( :extended ).should == true
|
56
|
+
class ClassProof
|
57
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock02
|
58
|
+
end
|
59
|
+
block_ran.should == false
|
60
|
+
class ClassProof2
|
61
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock02
|
62
|
+
end
|
63
|
+
block_ran.should == true
|
64
|
+
block_ran = false
|
65
|
+
Object.new.instance_eval do
|
66
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock02
|
67
|
+
end
|
68
|
+
block_ran.should == false
|
69
|
+
module ModuleProof
|
70
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock02
|
71
|
+
end
|
72
|
+
block_ran.should == false
|
73
|
+
module ModuleProof2
|
74
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock02
|
75
|
+
end
|
76
|
+
block_ran.should == true
|
77
|
+
end end
|
78
|
+
|
79
|
+
#######################################
|
80
|
+
# class_or_module_include_or_extend #
|
81
|
+
#######################################
|
82
|
+
|
83
|
+
it 'can run a block on class or module include or extend' do
|
84
|
+
module ModuleCluster::Define::Block::ClassOrModule::Mock03
|
85
|
+
extend ModuleCluster::Define::Block::ClassOrModule
|
86
|
+
block_ran = false
|
87
|
+
class_or_module_include_or_extend do
|
88
|
+
block_ran = true
|
89
|
+
self.should == ModuleCluster::Define::Block::ClassOrModule::Mock03
|
90
|
+
end
|
91
|
+
respond_to?( :extended ).should == true
|
92
|
+
class ClassProof
|
93
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock03
|
94
|
+
end
|
95
|
+
block_ran.should == true
|
96
|
+
block_ran = false
|
97
|
+
class ClassProof2
|
98
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock03
|
99
|
+
end
|
100
|
+
block_ran.should == true
|
101
|
+
block_ran = false
|
102
|
+
Object.new.instance_eval do
|
103
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock03
|
104
|
+
end
|
105
|
+
block_ran.should == false
|
106
|
+
module ModuleProof
|
107
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock03
|
108
|
+
end
|
109
|
+
block_ran.should == true
|
110
|
+
block_ran = false
|
111
|
+
module ModuleProof2
|
112
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock03
|
113
|
+
end
|
114
|
+
block_ran.should == true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
#####################################
|
119
|
+
# prepend_class_or_module_include #
|
120
|
+
#####################################
|
121
|
+
|
122
|
+
it 'can run a block before class or module include' do
|
123
|
+
module ModuleCluster::Define::Block::ClassOrModule::Mock04
|
124
|
+
extend ModuleCluster::Define::Block::ClassOrModule
|
125
|
+
block_ran = false
|
126
|
+
prepend_class_or_module_include do
|
127
|
+
block_ran = true
|
128
|
+
self.should == ModuleCluster::Define::Block::ClassOrModule::Mock04
|
129
|
+
end
|
130
|
+
respond_to?( :included ).should == true
|
131
|
+
class ClassProof
|
132
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock04
|
133
|
+
end
|
134
|
+
block_ran.should == false
|
135
|
+
class ClassProof2
|
136
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock04
|
137
|
+
end
|
138
|
+
block_ran.should == true
|
139
|
+
block_ran = false
|
140
|
+
Object.new.instance_eval do
|
141
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock04
|
142
|
+
end
|
143
|
+
block_ran.should == false
|
144
|
+
module ModuleProof
|
145
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock04
|
146
|
+
end
|
147
|
+
block_ran.should == false
|
148
|
+
module ModuleProof2
|
149
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock04
|
150
|
+
end
|
151
|
+
block_ran.should == true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
####################################
|
156
|
+
# prepend_class_or_module_extend #
|
157
|
+
####################################
|
158
|
+
|
159
|
+
it 'can run a block before class or module extend' do
|
160
|
+
module ModuleCluster::Define::Block::ClassOrModule::Mock05
|
161
|
+
extend ModuleCluster::Define::Block::ClassOrModule
|
162
|
+
block_ran = false
|
163
|
+
prepend_class_or_module_extend do
|
164
|
+
block_ran = true
|
165
|
+
self.should == ModuleCluster::Define::Block::ClassOrModule::Mock05
|
166
|
+
end
|
167
|
+
respond_to?( :extended ).should == true
|
168
|
+
class ClassProof
|
169
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock05
|
170
|
+
end
|
171
|
+
block_ran.should == false
|
172
|
+
class ClassProof2
|
173
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock05
|
174
|
+
end
|
175
|
+
block_ran.should == true
|
176
|
+
block_ran = false
|
177
|
+
Object.new.instance_eval do
|
178
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock05
|
179
|
+
end
|
180
|
+
block_ran.should == false
|
181
|
+
module ModuleProof
|
182
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock05
|
183
|
+
end
|
184
|
+
block_ran.should == false
|
185
|
+
module ModuleProof2
|
186
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock05
|
187
|
+
end
|
188
|
+
block_ran.should == true
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
###############################################
|
193
|
+
# prepend_class_or_module_include_or_extend #
|
194
|
+
###############################################
|
195
|
+
|
196
|
+
it 'can run a block before class or module include or extend' do
|
197
|
+
module ModuleCluster::Define::Block::ClassOrModule::Mock06
|
198
|
+
extend ModuleCluster::Define::Block::ClassOrModule
|
199
|
+
block_ran = false
|
200
|
+
prepend_class_or_module_include_or_extend do
|
201
|
+
block_ran = true
|
202
|
+
self.should == ModuleCluster::Define::Block::ClassOrModule::Mock06
|
203
|
+
end
|
204
|
+
respond_to?( :extended ).should == true
|
205
|
+
class ClassProof
|
206
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock06
|
207
|
+
end
|
208
|
+
block_ran.should == true
|
209
|
+
block_ran = false
|
210
|
+
class ClassProof2
|
211
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock06
|
212
|
+
end
|
213
|
+
block_ran.should == true
|
214
|
+
block_ran = false
|
215
|
+
Object.new.instance_eval do
|
216
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock06
|
217
|
+
end
|
218
|
+
block_ran.should == false
|
219
|
+
module ModuleProof
|
220
|
+
include ModuleCluster::Define::Block::ClassOrModule::Mock06
|
221
|
+
end
|
222
|
+
block_ran.should == true
|
223
|
+
block_ran = false
|
224
|
+
module ModuleProof2
|
225
|
+
extend ModuleCluster::Define::Block::ClassOrModule::Mock06
|
226
|
+
end
|
227
|
+
block_ran.should == true
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|