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