cascading-configuration-array 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,519 @@
1
+
2
+ require_relative '../../lib/cascading-configuration-array.rb'
3
+
4
+ describe CascadingConfiguration::CompositingArray do
5
+
6
+ #########
7
+ # []= #
8
+ #########
9
+
10
+ it 'can add elements' do
11
+ # primary class
12
+ class CascadingConfiguration::CompositingArray::Mock01
13
+ include CascadingConfiguration::Variable
14
+ include CascadingConfiguration::CompositingArray::Instance
15
+ end
16
+ working_instance = CascadingConfiguration::CompositingArray::Mock01
17
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
18
+ cascading_composite_array[0] = :some_setting
19
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
20
+ cascading_composite_array.should == [ :some_setting ]
21
+ cascading_composite_array[1] = :other_setting
22
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
23
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
24
+ # instance
25
+ working_instance = CascadingConfiguration::CompositingArray::Mock01.new
26
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
27
+ cascading_composite_array.local_cascading_array.should == []
28
+ cascading_composite_array[0] = :another_setting
29
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
30
+ cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
31
+ # inheriting class
32
+ class CascadingConfiguration::CompositingArray::Mock01sub1 < CascadingConfiguration::CompositingArray::Mock01
33
+ end
34
+ working_instance = CascadingConfiguration::CompositingArray::Mock01sub1
35
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
36
+ cascading_composite_array.local_cascading_array.should == []
37
+ cascading_composite_array[0] = :yet_another_setting
38
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
39
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
40
+ # instance
41
+ working_instance = CascadingConfiguration::CompositingArray::Mock01sub1.new
42
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
43
+ cascading_composite_array.local_cascading_array.should == []
44
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
45
+ cascading_composite_array[0] = :and_still_another_setting
46
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
47
+ cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
48
+ end
49
+
50
+ ########
51
+ # << #
52
+ ########
53
+
54
+ it 'can add elements' do
55
+ # primary class
56
+ class CascadingConfiguration::CompositingArray::Mock02
57
+ include CascadingConfiguration::Variable
58
+ include CascadingConfiguration::CompositingArray::Instance
59
+ end
60
+ working_instance = CascadingConfiguration::CompositingArray::Mock02
61
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
62
+ cascading_composite_array << :some_setting
63
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
64
+ cascading_composite_array.should == [ :some_setting ]
65
+ cascading_composite_array << :other_setting
66
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
67
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
68
+ # instance
69
+ working_instance = CascadingConfiguration::CompositingArray::Mock02.new
70
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
71
+ cascading_composite_array.local_cascading_array.should == []
72
+ cascading_composite_array << :another_setting
73
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
74
+ cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
75
+ # inheriting class
76
+ class CascadingConfiguration::CompositingArray::Mock02sub1 < CascadingConfiguration::CompositingArray::Mock02
77
+ end
78
+ working_instance = CascadingConfiguration::CompositingArray::Mock02sub1
79
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
80
+ cascading_composite_array.local_cascading_array.should == []
81
+ cascading_composite_array << :yet_another_setting
82
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
83
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
84
+ # instance
85
+ working_instance = CascadingConfiguration::CompositingArray::Mock02sub1.new
86
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
87
+ cascading_composite_array.local_cascading_array.should == []
88
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
89
+ cascading_composite_array << :and_still_another_setting
90
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
91
+ cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
92
+ end
93
+
94
+ #######
95
+ # + #
96
+ #######
97
+
98
+ it 'can add elements' do
99
+ # primary class
100
+ class CascadingConfiguration::CompositingArray::Mock03
101
+ include CascadingConfiguration::Variable
102
+ include CascadingConfiguration::CompositingArray::Instance
103
+ end
104
+ working_instance = CascadingConfiguration::CompositingArray::Mock03
105
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
106
+ cascading_composite_array += :some_setting
107
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
108
+ cascading_composite_array.should == [ :some_setting ]
109
+ cascading_composite_array += :other_setting
110
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
111
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
112
+ # instance
113
+ working_instance = CascadingConfiguration::CompositingArray::Mock03.new
114
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
115
+ cascading_composite_array.local_cascading_array.should == []
116
+ cascading_composite_array += :another_setting
117
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
118
+ cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
119
+ # inheriting class
120
+ class CascadingConfiguration::CompositingArray::Mock03sub1 < CascadingConfiguration::CompositingArray::Mock03
121
+ end
122
+ working_instance = CascadingConfiguration::CompositingArray::Mock03sub1
123
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
124
+ cascading_composite_array.local_cascading_array.should == []
125
+ cascading_composite_array += :yet_another_setting
126
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
127
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
128
+ # instance
129
+ working_instance = CascadingConfiguration::CompositingArray::Mock03sub1.new
130
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
131
+ cascading_composite_array.local_cascading_array.should == []
132
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
133
+ cascading_composite_array += :and_still_another_setting
134
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
135
+ cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
136
+ end
137
+
138
+ ############
139
+ # concat #
140
+ ############
141
+
142
+ it 'can add elements' do
143
+ # primary class
144
+ class CascadingConfiguration::CompositingArray::Mock04
145
+ include CascadingConfiguration::Variable
146
+ include CascadingConfiguration::CompositingArray::Instance
147
+ end
148
+ working_instance = CascadingConfiguration::CompositingArray::Mock04
149
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
150
+ cascading_composite_array.concat [ :some_setting ]
151
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
152
+ cascading_composite_array.should == [ :some_setting ]
153
+ cascading_composite_array.concat [ :other_setting ]
154
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
155
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
156
+ # instance
157
+ working_instance = CascadingConfiguration::CompositingArray::Mock04.new
158
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
159
+ cascading_composite_array.local_cascading_array.should == []
160
+ cascading_composite_array.concat [ :another_setting ]
161
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
162
+ cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
163
+ # inheriting class
164
+ class CascadingConfiguration::CompositingArray::Mock04sub1 < CascadingConfiguration::CompositingArray::Mock04
165
+ end
166
+ working_instance = CascadingConfiguration::CompositingArray::Mock04sub1
167
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
168
+ cascading_composite_array.local_cascading_array.should == []
169
+ cascading_composite_array.concat [ :yet_another_setting ]
170
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
171
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
172
+ # instance
173
+ working_instance = CascadingConfiguration::CompositingArray::Mock04sub1.new
174
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
175
+ cascading_composite_array.local_cascading_array.should == []
176
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
177
+ cascading_composite_array.concat [ :and_still_another_setting ]
178
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
179
+ cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
180
+ end
181
+
182
+ ##########
183
+ # push #
184
+ ##########
185
+
186
+ it 'can add elements' do
187
+ # primary class
188
+ class CascadingConfiguration::CompositingArray::Mock05
189
+ include CascadingConfiguration::Variable
190
+ include CascadingConfiguration::CompositingArray::Instance
191
+ end
192
+ working_instance = CascadingConfiguration::CompositingArray::Mock05
193
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
194
+ cascading_composite_array.push :some_setting
195
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
196
+ cascading_composite_array.should == [ :some_setting ]
197
+ cascading_composite_array.push :other_setting
198
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
199
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
200
+ # instance
201
+ working_instance = CascadingConfiguration::CompositingArray::Mock05.new
202
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
203
+ cascading_composite_array.local_cascading_array.should == []
204
+ cascading_composite_array.push :another_setting
205
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
206
+ cascading_composite_array.should == [ :another_setting, :other_setting, :some_setting ]
207
+ # inheriting class
208
+ class CascadingConfiguration::CompositingArray::Mock05sub1 < CascadingConfiguration::CompositingArray::Mock05
209
+ end
210
+ working_instance = CascadingConfiguration::CompositingArray::Mock05sub1
211
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
212
+ cascading_composite_array.local_cascading_array.should == []
213
+ cascading_composite_array.push :yet_another_setting
214
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
215
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
216
+ # instance
217
+ working_instance = CascadingConfiguration::CompositingArray::Mock05sub1.new
218
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
219
+ cascading_composite_array.local_cascading_array.should == []
220
+ cascading_composite_array.should == [ :other_setting, :some_setting, :yet_another_setting ]
221
+ cascading_composite_array.push :and_still_another_setting
222
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
223
+ cascading_composite_array.should == [ :and_still_another_setting, :other_setting, :some_setting, :yet_another_setting ]
224
+ end
225
+
226
+ #######
227
+ # - #
228
+ #######
229
+
230
+ it 'can exclude elements' do
231
+ # primary class
232
+ class CascadingConfiguration::CompositingArray::Mock06
233
+ include CascadingConfiguration::Variable
234
+ include CascadingConfiguration::CompositingArray::Instance
235
+ end
236
+ working_instance = CascadingConfiguration::CompositingArray::Mock06
237
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
238
+ cascading_composite_array.push( :other_setting, :some_setting )
239
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
240
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
241
+ cascading_composite_array -= [ :other_setting ]
242
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
243
+ cascading_composite_array.should == [ :some_setting ]
244
+ # instance
245
+ working_instance = CascadingConfiguration::CompositingArray::Mock06.new
246
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
247
+ cascading_composite_array.local_cascading_array.should == []
248
+ cascading_composite_array += [ :another_setting ]
249
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
250
+ cascading_composite_array -= [ :some_setting ]
251
+ cascading_composite_array.should == [ :another_setting ]
252
+ # inheriting class
253
+ class CascadingConfiguration::CompositingArray::Mock06sub1 < CascadingConfiguration::CompositingArray::Mock06
254
+ end
255
+ working_instance = CascadingConfiguration::CompositingArray::Mock06sub1
256
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
257
+ cascading_composite_array.local_cascading_array.should == []
258
+ cascading_composite_array += [ :yet_another_setting ]
259
+ cascading_composite_array -= [ :some_setting ]
260
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
261
+ cascading_composite_array.should == [ :yet_another_setting ]
262
+ # instance
263
+ working_instance = CascadingConfiguration::CompositingArray::Mock06sub1.new
264
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
265
+ cascading_composite_array.local_cascading_array.should == []
266
+ cascading_composite_array.should == [ :yet_another_setting ]
267
+ cascading_composite_array += [ :and_still_another_setting ]
268
+ cascading_composite_array -= [ :yet_another_setting ]
269
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
270
+ cascading_composite_array.should == [ :and_still_another_setting ]
271
+ end
272
+
273
+ ############
274
+ # delete #
275
+ ############
276
+
277
+ it 'can exclude elements' do
278
+ # primary class
279
+ class CascadingConfiguration::CompositingArray::Mock07
280
+ include CascadingConfiguration::Variable
281
+ include CascadingConfiguration::CompositingArray::Instance
282
+ end
283
+ working_instance = CascadingConfiguration::CompositingArray::Mock07
284
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
285
+ cascading_composite_array.push( :other_setting, :some_setting )
286
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
287
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
288
+ cascading_composite_array.delete( :other_setting )
289
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
290
+ cascading_composite_array.should == [ :some_setting ]
291
+ # instance
292
+ working_instance = CascadingConfiguration::CompositingArray::Mock07.new
293
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
294
+ cascading_composite_array.local_cascading_array.should == []
295
+ cascading_composite_array += [ :another_setting ]
296
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
297
+ cascading_composite_array.delete( :some_setting )
298
+ cascading_composite_array.should == [ :another_setting ]
299
+ # inheriting class
300
+ class CascadingConfiguration::CompositingArray::Mock07sub1 < CascadingConfiguration::CompositingArray::Mock07
301
+ end
302
+ working_instance = CascadingConfiguration::CompositingArray::Mock07sub1
303
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
304
+ cascading_composite_array.local_cascading_array.should == []
305
+ cascading_composite_array += [ :yet_another_setting ]
306
+ cascading_composite_array.delete( :some_setting )
307
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
308
+ cascading_composite_array.should == [ :yet_another_setting ]
309
+ # instance
310
+ working_instance = CascadingConfiguration::CompositingArray::Mock07sub1.new
311
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
312
+ cascading_composite_array.local_cascading_array.should == []
313
+ cascading_composite_array.should == [ :yet_another_setting ]
314
+ cascading_composite_array += [ :and_still_another_setting ]
315
+ cascading_composite_array.delete( :yet_another_setting )
316
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
317
+ cascading_composite_array.should == [ :and_still_another_setting ]
318
+ end
319
+
320
+ #########
321
+ # pop #
322
+ #########
323
+
324
+ it 'can pop the final element' do
325
+ # primary class
326
+ class CascadingConfiguration::CompositingArray::Mock08
327
+ include CascadingConfiguration::Variable
328
+ include CascadingConfiguration::CompositingArray::Instance
329
+ end
330
+ working_instance = CascadingConfiguration::CompositingArray::Mock08
331
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
332
+ cascading_composite_array.push( :other_setting, :some_setting )
333
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
334
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
335
+ cascading_composite_array.pop.should == :some_setting
336
+ cascading_composite_array.local_cascading_array.should == [ :other_setting ]
337
+ cascading_composite_array.should == [ :other_setting ]
338
+ # instance
339
+ working_instance = CascadingConfiguration::CompositingArray::Mock08.new
340
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
341
+ cascading_composite_array.local_cascading_array.should == []
342
+ cascading_composite_array += :another_setting
343
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
344
+ cascading_composite_array.pop.should == :other_setting
345
+ cascading_composite_array.should == [ :another_setting ]
346
+ # inheriting class
347
+ class CascadingConfiguration::CompositingArray::Mock08sub1 < CascadingConfiguration::CompositingArray::Mock08
348
+ end
349
+ working_instance = CascadingConfiguration::CompositingArray::Mock08sub1
350
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
351
+ cascading_composite_array.local_cascading_array.should == []
352
+ cascading_composite_array.pop.should == :other_setting
353
+ cascading_composite_array.should == []
354
+ cascading_composite_array += :yet_another_setting
355
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
356
+ cascading_composite_array.should == [ :yet_another_setting ]
357
+ # instance
358
+ working_instance = CascadingConfiguration::CompositingArray::Mock08sub1.new
359
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
360
+ cascading_composite_array.local_cascading_array.should == []
361
+ cascading_composite_array.should == [ :yet_another_setting ]
362
+ cascading_composite_array.pop.should == :yet_another_setting
363
+ cascading_composite_array.should == []
364
+ cascading_composite_array += :and_still_another_setting
365
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
366
+ cascading_composite_array.should == [ :and_still_another_setting ]
367
+ end
368
+
369
+ ###########
370
+ # shift #
371
+ ###########
372
+
373
+ it 'can shift the first element' do
374
+ # primary class
375
+ class CascadingConfiguration::CompositingArray::Mock09
376
+ include CascadingConfiguration::Variable
377
+ include CascadingConfiguration::CompositingArray::Instance
378
+ end
379
+ working_instance = CascadingConfiguration::CompositingArray::Mock09
380
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
381
+ cascading_composite_array.push( :other_setting, :some_setting )
382
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
383
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
384
+ cascading_composite_array.shift
385
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
386
+ cascading_composite_array.should == [ :some_setting ]
387
+ # instance
388
+ working_instance = CascadingConfiguration::CompositingArray::Mock09.new
389
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
390
+ cascading_composite_array.local_cascading_array.should == []
391
+ cascading_composite_array.shift
392
+ cascading_composite_array.should == []
393
+ cascading_composite_array += :another_setting
394
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
395
+ cascading_composite_array.should == [ :another_setting ]
396
+ # inheriting class
397
+ class CascadingConfiguration::CompositingArray::Mock09sub1 < CascadingConfiguration::CompositingArray::Mock09
398
+ end
399
+ working_instance = CascadingConfiguration::CompositingArray::Mock09sub1
400
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
401
+ cascading_composite_array.local_cascading_array.should == []
402
+ cascading_composite_array.shift
403
+ cascading_composite_array.should == []
404
+ cascading_composite_array += :yet_another_setting
405
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
406
+ cascading_composite_array.should == [ :yet_another_setting ]
407
+ # instance
408
+ working_instance = CascadingConfiguration::CompositingArray::Mock09sub1.new
409
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
410
+ cascading_composite_array.local_cascading_array.should == []
411
+ cascading_composite_array.should == [ :yet_another_setting ]
412
+ cascading_composite_array.shift
413
+ cascading_composite_array.should == []
414
+ cascading_composite_array += :and_still_another_setting
415
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
416
+ cascading_composite_array.should == [ :and_still_another_setting ]
417
+ end
418
+
419
+ ############
420
+ # slice! #
421
+ ############
422
+
423
+ it 'can slice elements' do
424
+ # primary class
425
+ class CascadingConfiguration::CompositingArray::Mock10
426
+ include CascadingConfiguration::Variable
427
+ include CascadingConfiguration::CompositingArray::Instance
428
+ end
429
+ working_instance = CascadingConfiguration::CompositingArray::Mock10
430
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
431
+ cascading_composite_array.push( :other_setting, :some_setting )
432
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
433
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
434
+ cascading_composite_array.slice!( 0, 1 ).should == [ :other_setting ]
435
+ cascading_composite_array.local_cascading_array.should == [ :some_setting ]
436
+ cascading_composite_array.should == [ :some_setting ]
437
+ # instance
438
+ working_instance = CascadingConfiguration::CompositingArray::Mock10.new
439
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
440
+ cascading_composite_array.local_cascading_array.should == []
441
+ cascading_composite_array.slice!( 0, 1 ).should == [ :some_setting ]
442
+ cascading_composite_array.should == []
443
+ cascading_composite_array += :another_setting
444
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
445
+ cascading_composite_array.should == [ :another_setting ]
446
+ # inheriting class
447
+ class CascadingConfiguration::CompositingArray::Mock10sub1 < CascadingConfiguration::CompositingArray::Mock10
448
+ end
449
+ working_instance = CascadingConfiguration::CompositingArray::Mock10sub1
450
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
451
+ cascading_composite_array.local_cascading_array.should == []
452
+ cascading_composite_array.slice!( 0, 1 ).should == [ :some_setting ]
453
+ cascading_composite_array.should == []
454
+ cascading_composite_array += :yet_another_setting
455
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
456
+ cascading_composite_array.should == [ :yet_another_setting ]
457
+ # instance
458
+ working_instance = CascadingConfiguration::CompositingArray::Mock10sub1.new
459
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
460
+ cascading_composite_array.local_cascading_array.should == []
461
+ cascading_composite_array.should == [ :yet_another_setting ]
462
+ cascading_composite_array.slice!( 0, 1 ).should == [ :yet_another_setting ]
463
+ cascading_composite_array.should == []
464
+ cascading_composite_array += :and_still_another_setting
465
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
466
+ cascading_composite_array.should == [ :and_still_another_setting ]
467
+ end
468
+
469
+ ###########
470
+ # clear #
471
+ ###########
472
+
473
+ it 'can clear, causing present elements to be excluded' do
474
+ # primary class
475
+ class CascadingConfiguration::CompositingArray::Mock11
476
+ include CascadingConfiguration::Variable
477
+ include CascadingConfiguration::CompositingArray::Instance
478
+ end
479
+ working_instance = CascadingConfiguration::CompositingArray::Mock11
480
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
481
+ cascading_composite_array.push( :other_setting, :some_setting )
482
+ cascading_composite_array.local_cascading_array.should == [ :other_setting, :some_setting ]
483
+ cascading_composite_array.should == [ :other_setting, :some_setting ]
484
+ cascading_composite_array.clear
485
+ cascading_composite_array.local_cascading_array.should == []
486
+ cascading_composite_array.should == []
487
+ # instance
488
+ working_instance = CascadingConfiguration::CompositingArray::Mock11.new
489
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
490
+ cascading_composite_array.local_cascading_array.should == []
491
+ cascading_composite_array.clear
492
+ cascading_composite_array.should == []
493
+ cascading_composite_array += :another_setting
494
+ cascading_composite_array.local_cascading_array.should == [ :another_setting ]
495
+ cascading_composite_array.should == [ :another_setting ]
496
+ # inheriting class
497
+ class CascadingConfiguration::CompositingArray::Mock11sub1 < CascadingConfiguration::CompositingArray::Mock11
498
+ end
499
+ working_instance = CascadingConfiguration::CompositingArray::Mock11sub1
500
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
501
+ cascading_composite_array.local_cascading_array.should == []
502
+ cascading_composite_array.clear
503
+ cascading_composite_array.should == []
504
+ cascading_composite_array += :yet_another_setting
505
+ cascading_composite_array.local_cascading_array.should == [ :yet_another_setting ]
506
+ cascading_composite_array.should == [ :yet_another_setting ]
507
+ # instance
508
+ working_instance = CascadingConfiguration::CompositingArray::Mock11sub1.new
509
+ cascading_composite_array = working_instance.composite_array_for_cascading_configuration( :some_configuration )
510
+ cascading_composite_array.local_cascading_array.should == []
511
+ cascading_composite_array.should == [ :yet_another_setting ]
512
+ cascading_composite_array.clear
513
+ cascading_composite_array.should == []
514
+ cascading_composite_array += :and_still_another_setting
515
+ cascading_composite_array.local_cascading_array.should == [ :and_still_another_setting ]
516
+ cascading_composite_array.should == [ :and_still_another_setting ]
517
+ end
518
+
519
+ end
@@ -0,0 +1,155 @@
1
+
2
+ require_relative '../../lib/cascading-configuration-array.rb'
3
+
4
+ describe CascadingConfiguration::LocalConfigurationArray do
5
+
6
+ #########
7
+ # []= #
8
+ #########
9
+
10
+ it 'can add elements' do
11
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
12
+ array_instance[0] = :some_setting
13
+ array_instance.should == [ :some_setting ]
14
+ array_instance.exclude_array.include?( :some_setting ).should == false
15
+ array_instance[1] = :other_setting
16
+ array_instance.should == [ :other_setting, :some_setting ]
17
+ array_instance.exclude_array.include?( :other_setting ).should == false
18
+ end
19
+
20
+ ########
21
+ # << #
22
+ ########
23
+
24
+ it 'can add elements' do
25
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
26
+ array_instance << :some_setting
27
+ array_instance.should == [ :some_setting ]
28
+ array_instance.exclude_array.include?( :some_setting ).should == false
29
+ array_instance << :other_setting
30
+ array_instance.should == [ :other_setting, :some_setting ]
31
+ array_instance.exclude_array.include?( :other_setting ).should == false
32
+ end
33
+
34
+ #######
35
+ # + #
36
+ #######
37
+
38
+ it 'can add elements' do
39
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
40
+ array_instance += [ :some_setting ]
41
+ array_instance.should == [ :some_setting ]
42
+ array_instance.exclude_array.include?( :some_setting ).should == false
43
+ array_instance += [ :other_setting ]
44
+ array_instance.should == [ :other_setting, :some_setting ]
45
+ array_instance.exclude_array.include?( :other_setting ).should == false
46
+ end
47
+
48
+ ##########
49
+ # push #
50
+ ##########
51
+
52
+ it 'can add elements' do
53
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
54
+ array_instance.push( :some_setting )
55
+ array_instance.should == [ :some_setting ]
56
+ array_instance.exclude_array.include?( :some_setting ).should == false
57
+ array_instance.push( :other_setting )
58
+ array_instance.should == [ :other_setting, :some_setting ]
59
+ array_instance.exclude_array.include?( :other_setting ).should == false
60
+ end
61
+
62
+ ############
63
+ # concat #
64
+ ############
65
+
66
+ it 'can concat arrays' do
67
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
68
+ array_instance.concat( [ :some_setting ] )
69
+ array_instance.should == [ :some_setting ]
70
+ array_instance.exclude_array.include?( :some_setting ).should == false
71
+ array_instance.concat( [ :other_setting ] )
72
+ array_instance.should == [ :other_setting, :some_setting ]
73
+ array_instance.exclude_array.include?( :other_setting ).should == false
74
+ end
75
+
76
+ #######
77
+ # - #
78
+ #######
79
+
80
+ it 'can exclude elements' do
81
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
82
+ array_instance += [ :some_setting, :other_setting ]
83
+ array_instance -= [ :other_setting ]
84
+ array_instance.should == [ :some_setting ]
85
+ array_instance.exclude_array.include?( :other_setting ).should == true
86
+ array_instance -= [ :some_setting ]
87
+ array_instance.should == []
88
+ array_instance.exclude_array.include?( :some_setting ).should == true
89
+ end
90
+
91
+ ############
92
+ # delete #
93
+ ############
94
+
95
+ it 'can exclude elements' do
96
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
97
+ array_instance += [ :some_setting, :other_setting ]
98
+ array_instance.delete( :other_setting )
99
+ array_instance.should == [ :some_setting ]
100
+ array_instance.exclude_array.include?( :other_setting ).should == true
101
+ array_instance.delete( :some_setting )
102
+ array_instance.should == []
103
+ array_instance.exclude_array.include?( :some_setting ).should == true
104
+ end
105
+
106
+ #########
107
+ # pop #
108
+ #########
109
+
110
+ it 'can pop the final element' do
111
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
112
+ array_instance += [ :other_setting, :some_setting ]
113
+ array_instance.pop.should == :some_setting
114
+ array_instance.should == [ :other_setting ]
115
+ array_instance.exclude_array.include?( :some_setting ).should == true
116
+ end
117
+
118
+ ###########
119
+ # shift #
120
+ ###########
121
+
122
+ it 'can shift the first element' do
123
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
124
+ array_instance += [ :other_setting, :some_setting ]
125
+ array_instance.shift.should == :other_setting
126
+ array_instance.should == [ :some_setting ]
127
+ array_instance.exclude_array.include?( :other_setting ).should == true
128
+ end
129
+
130
+ ############
131
+ # slice! #
132
+ ############
133
+
134
+ it 'can slice elements' do
135
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
136
+ array_instance += [ :other_setting, :some_setting ]
137
+ array_instance.slice!( 0, 1 ).should == [ :other_setting ]
138
+ array_instance.should == [ :some_setting ]
139
+ array_instance.exclude_array.include?( :other_setting ).should == true
140
+ end
141
+
142
+ ###########
143
+ # clear #
144
+ ###########
145
+
146
+ it 'can clear, causing present elements to be excluded' do
147
+ array_instance = CascadingConfiguration::LocalConfigurationArray.new
148
+ array_instance += [ :some_setting, :other_setting ]
149
+ array_instance.clear
150
+ array_instance.should == []
151
+ array_instance.exclude_array.include?( :some_setting ).should == true
152
+ array_instance.exclude_array.include?( :other_setting ).should == true
153
+ end
154
+
155
+ end