module-cluster 1.4.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,559 @@
1
+
2
+ require_relative '../../../lib/module-cluster.rb'
3
+
4
+ describe ModuleCluster::Suspend::WithoutHooks do
5
+
6
+ #######################
7
+ # without_any_hooks #
8
+ #######################
9
+
10
+ it 'can suspend and resume all hooks at once or all hooks matching a description' do
11
+ module ModuleCluster::Suspend::WithoutHooks::Mock01
12
+ extend ModuleCluster::Suspend::WithoutHooks
13
+ # required to provide #cluster_stack
14
+ extend ModuleCluster::CascadeFeatures::ClusterStack
15
+ module Module1
16
+ end
17
+ module Module2
18
+ end
19
+ module Module3
20
+ end
21
+ module Module4
22
+ end
23
+ # prepend include
24
+ prepend_include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
25
+ prepend_include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
26
+ prepend_include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
27
+ prepend_include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
28
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
29
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
30
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
31
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
32
+ # prepend extend
33
+ prepend_extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
34
+ prepend_extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
35
+ prepend_extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
36
+ prepend_extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
37
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
38
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
39
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
40
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
41
+ # include
42
+ include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
43
+ include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
44
+ include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
45
+ include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
46
+ cluster_stack.include_hooks.push( include_set_one )
47
+ cluster_stack.include_hooks.push( include_set_two )
48
+ cluster_stack.include_hooks.push( include_set_three )
49
+ cluster_stack.include_hooks.push( include_set_four )
50
+ # extend
51
+ extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
52
+ extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
53
+ extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
54
+ extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
55
+ cluster_stack.extend_hooks.push( extend_set_one )
56
+ cluster_stack.extend_hooks.push( extend_set_two )
57
+ cluster_stack.extend_hooks.push( extend_set_three )
58
+ cluster_stack.extend_hooks.push( extend_set_four )
59
+
60
+ # suspend all hooks
61
+ without_any_hooks do
62
+ all_hooks_suspended?.should == true
63
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
64
+ end
65
+ all_hooks_suspended?.should == false
66
+
67
+ # suspend hooks by description
68
+ without_any_hooks( :name => :one ) do
69
+ all_hooks_suspended?.should == false
70
+ prepend_include_set_one.suspended.should == true
71
+ prepend_extend_set_one.suspended.should == true
72
+ include_set_one.suspended.should == true
73
+ extend_set_one.suspended.should == true
74
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
75
+ end
76
+ prepend_include_set_one.suspended.should == false
77
+ prepend_extend_set_one.suspended.should == false
78
+ include_set_one.suspended.should == false
79
+ extend_set_one.suspended.should == false
80
+ all_hooks_suspended?.should == false
81
+
82
+ end
83
+ end
84
+
85
+ ###############################
86
+ # without_any_include_hooks #
87
+ ###############################
88
+
89
+ it 'can suspend and resume all include or prepending include hooks at once or any include or prepending include hooks matching a description' do
90
+ module ModuleCluster::Suspend::WithoutHooks::Mock02
91
+ extend ModuleCluster::Suspend::WithoutHooks
92
+ # required to provide #cluster_stack
93
+ extend ModuleCluster::CascadeFeatures::ClusterStack
94
+ module Module1
95
+ end
96
+ module Module2
97
+ end
98
+ module Module3
99
+ end
100
+ module Module4
101
+ end
102
+ # prepend include
103
+ prepend_include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
104
+ prepend_include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
105
+ prepend_include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
106
+ prepend_include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
107
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
108
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
109
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
110
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
111
+ # prepend extend
112
+ prepend_extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
113
+ prepend_extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
114
+ prepend_extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
115
+ prepend_extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
116
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
117
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
118
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
119
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
120
+ # include
121
+ include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
122
+ include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
123
+ include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
124
+ include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
125
+ cluster_stack.include_hooks.push( include_set_one )
126
+ cluster_stack.include_hooks.push( include_set_two )
127
+ cluster_stack.include_hooks.push( include_set_three )
128
+ cluster_stack.include_hooks.push( include_set_four )
129
+ # extend
130
+ extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
131
+ extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
132
+ extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
133
+ extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
134
+ cluster_stack.extend_hooks.push( extend_set_one )
135
+ cluster_stack.extend_hooks.push( extend_set_two )
136
+ cluster_stack.extend_hooks.push( extend_set_three )
137
+ cluster_stack.extend_hooks.push( extend_set_four )
138
+
139
+ # suspend all hooks
140
+ suspend_any_include_hooks
141
+ all_include_hooks_suspended?.should == true
142
+ cluster_stack.all_include_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
143
+ resume_any_include_hooks
144
+ all_include_hooks_suspended?.should == false
145
+
146
+ # suspend hooks by description
147
+ suspend_any_include_hooks( :name => :one )
148
+ all_include_hooks_suspended?.should == false
149
+ prepend_include_set_one.suspended.should == true
150
+ prepend_extend_set_one.suspended.should == false
151
+ include_set_one.suspended.should == true
152
+ extend_set_one.suspended.should == false
153
+ cluster_stack.all_include_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
154
+ resume_any_include_hooks( :name => :one )
155
+ prepend_include_set_one.suspended.should == false
156
+ prepend_extend_set_one.suspended.should == false
157
+ include_set_one.suspended.should == false
158
+ extend_set_one.suspended.should == false
159
+ all_include_hooks_suspended?.should == false
160
+
161
+ end
162
+ end
163
+
164
+ ##############################
165
+ # without_any_extend_hooks #
166
+ ##############################
167
+
168
+ it 'can suspend and resume all extend or prepending extend hooks at once or any extend or prepending extend hooks matching a description' do
169
+ module ModuleCluster::Suspend::WithoutHooks::Mock03
170
+ extend ModuleCluster::Suspend::WithoutHooks
171
+ # required to provide #cluster_stack
172
+ extend ModuleCluster::CascadeFeatures::ClusterStack
173
+ module Module1
174
+ end
175
+ module Module2
176
+ end
177
+ module Module3
178
+ end
179
+ module Module4
180
+ end
181
+ # prepend include
182
+ prepend_include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
183
+ prepend_include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
184
+ prepend_include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
185
+ prepend_include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
186
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
187
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
188
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
189
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
190
+ # prepend extend
191
+ prepend_extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
192
+ prepend_extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
193
+ prepend_extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
194
+ prepend_extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
195
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
196
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
197
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
198
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
199
+ # include
200
+ include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
201
+ include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
202
+ include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
203
+ include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
204
+ cluster_stack.include_hooks.push( include_set_one )
205
+ cluster_stack.include_hooks.push( include_set_two )
206
+ cluster_stack.include_hooks.push( include_set_three )
207
+ cluster_stack.include_hooks.push( include_set_four )
208
+ # extend
209
+ extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
210
+ extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
211
+ extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
212
+ extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
213
+ cluster_stack.extend_hooks.push( extend_set_one )
214
+ cluster_stack.extend_hooks.push( extend_set_two )
215
+ cluster_stack.extend_hooks.push( extend_set_three )
216
+ cluster_stack.extend_hooks.push( extend_set_four )
217
+
218
+ # suspend all hooks
219
+ without_any_extend_hooks do
220
+ all_extend_hooks_suspended?.should == true
221
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
222
+ end
223
+ all_extend_hooks_suspended?.should == false
224
+
225
+ # suspend hooks by description
226
+ without_any_extend_hooks( :name => :one ) do
227
+ all_extend_hooks_suspended?.should == false
228
+ prepend_include_set_one.suspended.should == false
229
+ prepend_extend_set_one.suspended.should == true
230
+ include_set_one.suspended.should == false
231
+ extend_set_one.suspended.should == true
232
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
233
+ end
234
+ prepend_include_set_one.suspended.should == false
235
+ prepend_extend_set_one.suspended.should == false
236
+ include_set_one.suspended.should == false
237
+ extend_set_one.suspended.should == false
238
+ all_extend_hooks_suspended?.should == false
239
+
240
+ end
241
+ end
242
+
243
+ ###########################
244
+ # without_include_hooks #
245
+ ###########################
246
+
247
+ it 'can suspend and resume all include hooks at once or any include hooks matching a description' do
248
+ module ModuleCluster::Suspend::WithoutHooks::Mock04
249
+ extend ModuleCluster::Suspend::WithoutHooks
250
+ # required to provide #cluster_stack
251
+ extend ModuleCluster::CascadeFeatures::ClusterStack
252
+ module Module1
253
+ end
254
+ module Module2
255
+ end
256
+ module Module3
257
+ end
258
+ module Module4
259
+ end
260
+ # prepend include
261
+ prepend_include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
262
+ prepend_include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
263
+ prepend_include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
264
+ prepend_include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
265
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
266
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
267
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
268
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
269
+ # prepend extend
270
+ prepend_extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
271
+ prepend_extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
272
+ prepend_extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
273
+ prepend_extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
274
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
275
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
276
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
277
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
278
+ # include
279
+ include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
280
+ include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
281
+ include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
282
+ include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
283
+ cluster_stack.include_hooks.push( include_set_one )
284
+ cluster_stack.include_hooks.push( include_set_two )
285
+ cluster_stack.include_hooks.push( include_set_three )
286
+ cluster_stack.include_hooks.push( include_set_four )
287
+ # extend
288
+ extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
289
+ extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
290
+ extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
291
+ extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
292
+ cluster_stack.extend_hooks.push( extend_set_one )
293
+ cluster_stack.extend_hooks.push( extend_set_two )
294
+ cluster_stack.extend_hooks.push( extend_set_three )
295
+ cluster_stack.extend_hooks.push( extend_set_four )
296
+
297
+ # suspend all hooks
298
+ without_include_hooks do
299
+ include_hooks_suspended?.should == true
300
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
301
+ end
302
+ include_hooks_suspended?.should == false
303
+
304
+ # suspend hooks by description
305
+ without_include_hooks( :name => :one ) do
306
+ include_hooks_suspended?.should == false
307
+ prepend_include_set_one.suspended.should == false
308
+ prepend_extend_set_one.suspended.should == false
309
+ include_set_one.suspended.should == true
310
+ extend_set_one.suspended.should == false
311
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
312
+ end
313
+ prepend_include_set_one.suspended.should == false
314
+ prepend_extend_set_one.suspended.should == false
315
+ include_set_one.suspended.should == false
316
+ extend_set_one.suspended.should == false
317
+ include_hooks_suspended?.should == false
318
+
319
+ end
320
+ end
321
+
322
+ ##########################
323
+ # without_extend_hooks #
324
+ ##########################
325
+
326
+ it 'can suspend and resume all extend hooks at once or any extend hooks matching a description' do
327
+ module ModuleCluster::Suspend::WithoutHooks::Mock05
328
+ extend ModuleCluster::Suspend::WithoutHooks
329
+ # required to provide #cluster_stack
330
+ extend ModuleCluster::CascadeFeatures::ClusterStack
331
+ module Module1
332
+ end
333
+ module Module2
334
+ end
335
+ module Module3
336
+ end
337
+ module Module4
338
+ end
339
+ # prepend include
340
+ prepend_include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
341
+ prepend_include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
342
+ prepend_include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
343
+ prepend_include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
344
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
345
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
346
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
347
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
348
+ # prepend extend
349
+ prepend_extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
350
+ prepend_extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
351
+ prepend_extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
352
+ prepend_extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
353
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
354
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
355
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
356
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
357
+ # include
358
+ include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
359
+ include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
360
+ include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
361
+ include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
362
+ cluster_stack.include_hooks.push( include_set_one )
363
+ cluster_stack.include_hooks.push( include_set_two )
364
+ cluster_stack.include_hooks.push( include_set_three )
365
+ cluster_stack.include_hooks.push( include_set_four )
366
+ # extend
367
+ extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
368
+ extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
369
+ extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
370
+ extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
371
+ cluster_stack.extend_hooks.push( extend_set_one )
372
+ cluster_stack.extend_hooks.push( extend_set_two )
373
+ cluster_stack.extend_hooks.push( extend_set_three )
374
+ cluster_stack.extend_hooks.push( extend_set_four )
375
+
376
+ # suspend all hooks
377
+ without_extend_hooks do
378
+ extend_hooks_suspended?.should == true
379
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
380
+ end
381
+ extend_hooks_suspended?.should == false
382
+
383
+ # suspend hooks by description
384
+ without_extend_hooks( :name => :one ) do
385
+ extend_hooks_suspended?.should == false
386
+ prepend_include_set_one.suspended.should == false
387
+ prepend_extend_set_one.suspended.should == false
388
+ include_set_one.suspended.should == false
389
+ extend_set_one.suspended.should == true
390
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
391
+ end
392
+ prepend_include_set_one.suspended.should == false
393
+ prepend_extend_set_one.suspended.should == false
394
+ include_set_one.suspended.should == false
395
+ extend_set_one.suspended.should == false
396
+ extend_hooks_suspended?.should == false
397
+
398
+ end
399
+ end
400
+
401
+ ###################################
402
+ # without_prepend_include_hooks #
403
+ ###################################
404
+
405
+ it 'can suspend and resume all prepending include hooks at once or any prepending include hooks matching a description' do
406
+ module ModuleCluster::Suspend::WithoutHooks::Mock06
407
+ extend ModuleCluster::Suspend::WithoutHooks
408
+ # required to provide #cluster_stack
409
+ extend ModuleCluster::CascadeFeatures::ClusterStack
410
+ module Module1
411
+ end
412
+ module Module2
413
+ end
414
+ module Module3
415
+ end
416
+ module Module4
417
+ end
418
+ # prepend include
419
+ prepend_include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
420
+ prepend_include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
421
+ prepend_include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
422
+ prepend_include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
423
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
424
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
425
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
426
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
427
+ # prepend extend
428
+ prepend_extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
429
+ prepend_extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
430
+ prepend_extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
431
+ prepend_extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
432
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
433
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
434
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
435
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
436
+ # include
437
+ include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
438
+ include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
439
+ include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
440
+ include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
441
+ cluster_stack.include_hooks.push( include_set_one )
442
+ cluster_stack.include_hooks.push( include_set_two )
443
+ cluster_stack.include_hooks.push( include_set_three )
444
+ cluster_stack.include_hooks.push( include_set_four )
445
+ # extend
446
+ extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
447
+ extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
448
+ extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
449
+ extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
450
+ cluster_stack.extend_hooks.push( extend_set_one )
451
+ cluster_stack.extend_hooks.push( extend_set_two )
452
+ cluster_stack.extend_hooks.push( extend_set_three )
453
+ cluster_stack.extend_hooks.push( extend_set_four )
454
+
455
+ # suspend all hooks
456
+ without_prepend_include_hooks do
457
+ prepend_include_hooks_suspended?.should == true
458
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
459
+ end
460
+ prepend_include_hooks_suspended?.should == false
461
+
462
+ # suspend hooks by description
463
+ without_prepend_include_hooks( :name => :one ) do
464
+ prepend_include_hooks_suspended?.should == false
465
+ prepend_include_set_one.suspended.should == true
466
+ prepend_extend_set_one.suspended.should == false
467
+ include_set_one.suspended.should == false
468
+ extend_set_one.suspended.should == false
469
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
470
+ end
471
+ prepend_include_set_one.suspended.should == false
472
+ prepend_extend_set_one.suspended.should == false
473
+ include_set_one.suspended.should == false
474
+ extend_set_one.suspended.should == false
475
+ prepend_include_hooks_suspended?.should == false
476
+
477
+ end
478
+ end
479
+
480
+ ##################################
481
+ # without_prepend_extend_hooks #
482
+ ##################################
483
+
484
+ it 'can suspend and resume all prepending extend hooks at once or any prepending extend hooks matching a description' do
485
+ module ModuleCluster::Suspend::WithoutHooks::Mock07
486
+ extend ModuleCluster::Suspend::WithoutHooks
487
+ # required to provide #cluster_stack
488
+ extend ModuleCluster::CascadeFeatures::ClusterStack
489
+ module Module1
490
+ end
491
+ module Module2
492
+ end
493
+ module Module3
494
+ end
495
+ module Module4
496
+ end
497
+ # prepend include
498
+ prepend_include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
499
+ prepend_include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
500
+ prepend_include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
501
+ prepend_include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
502
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_one )
503
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_two )
504
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_three )
505
+ cluster_stack.prepend_include_hooks.push( prepend_include_set_four )
506
+ # prepend extend
507
+ prepend_extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
508
+ prepend_extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, true, :two )
509
+ prepend_extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
510
+ prepend_extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
511
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_one )
512
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_two )
513
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_three )
514
+ cluster_stack.prepend_extend_hooks.push( prepend_extend_set_four )
515
+ # include
516
+ include_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
517
+ include_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
518
+ include_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, true, :three )
519
+ include_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, false, :four )
520
+ cluster_stack.include_hooks.push( include_set_one )
521
+ cluster_stack.include_hooks.push( include_set_two )
522
+ cluster_stack.include_hooks.push( include_set_three )
523
+ cluster_stack.include_hooks.push( include_set_four )
524
+ # extend
525
+ extend_set_one = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module1 ], nil, false, :one )
526
+ extend_set_two = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include, [ Module2 ], nil, false, :two )
527
+ extend_set_three = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :extend, [ Module3 ], nil, false, :three )
528
+ extend_set_four = ModuleCluster::ClusterStack::Set.new( Kernel, :some_method, :all, :include_and_extend, [ Module4 ], nil, true, :four )
529
+ cluster_stack.extend_hooks.push( extend_set_one )
530
+ cluster_stack.extend_hooks.push( extend_set_two )
531
+ cluster_stack.extend_hooks.push( extend_set_three )
532
+ cluster_stack.extend_hooks.push( extend_set_four )
533
+
534
+ # suspend all hooks
535
+ without_prepend_extend_hooks do
536
+ prepend_extend_hooks_suspended?.should == true
537
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
538
+ end
539
+ prepend_extend_hooks_suspended?.should == false
540
+
541
+ # suspend hooks by description
542
+ without_prepend_extend_hooks( :name => :one ) do
543
+ prepend_extend_hooks_suspended?.should == false
544
+ prepend_include_set_one.suspended.should == false
545
+ prepend_extend_set_one.suspended.should == true
546
+ include_set_one.suspended.should == false
547
+ extend_set_one.suspended.should == false
548
+ cluster_stack.all_hooks.collect { |this_hook| ! this_hook.suspended }.empty?.should == false
549
+ end
550
+ prepend_include_set_one.suspended.should == false
551
+ prepend_extend_set_one.suspended.should == false
552
+ include_set_one.suspended.should == false
553
+ extend_set_one.suspended.should == false
554
+ prepend_extend_hooks_suspended?.should == false
555
+
556
+ end
557
+ end
558
+
559
+ end