cascading-configuration-hash 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,402 +0,0 @@
1
-
2
- require_relative '../../lib/cascading-configuration-hash.rb'
3
-
4
- describe CascadingConfiguration::CompositingHash do
5
-
6
- #########
7
- # []= #
8
- #########
9
-
10
- it 'can add elements' do
11
- # primary class
12
- class CascadingConfiguration::CompositingHash::Mock01
13
- include CascadingConfiguration::Variable
14
- include CascadingConfiguration::CompositingHash::Instance
15
- end
16
- working_instance = CascadingConfiguration::CompositingHash::Mock01
17
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
18
- cascading_composite_hash[ :some_setting ] = :some_value
19
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
20
- cascading_composite_hash.should == { :some_setting => :some_value }
21
- cascading_composite_hash[ :other_setting ] = :some_value
22
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
23
- :other_setting => :some_value }
24
- cascading_composite_hash.should == { :some_setting => :some_value,
25
- :other_setting => :some_value }
26
- # instance
27
- working_instance = CascadingConfiguration::CompositingHash::Mock01.new
28
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
29
- cascading_composite_hash.local_cascading_hash.should == {}
30
- cascading_composite_hash.should == { :some_setting => :some_value,
31
- :other_setting => :some_value }
32
- cascading_composite_hash[ :another_setting ] = :some_value
33
- cascading_composite_hash.local_cascading_hash.should == { :another_setting => :some_value }
34
- cascading_composite_hash.should == { :some_setting => :some_value,
35
- :other_setting => :some_value,
36
- :another_setting => :some_value }
37
- # inheriting class
38
- class CascadingConfiguration::CompositingHash::Mock01sub1 < CascadingConfiguration::CompositingHash::Mock01
39
- end
40
- working_instance = CascadingConfiguration::CompositingHash::Mock01sub1
41
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
42
- cascading_composite_hash.local_cascading_hash.should == {}
43
- cascading_composite_hash.should == { :some_setting => :some_value,
44
- :other_setting => :some_value }
45
- cascading_composite_hash[ :yet_another_setting ] = :some_value
46
- cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
47
- cascading_composite_hash.should == { :some_setting => :some_value,
48
- :other_setting => :some_value,
49
- :yet_another_setting => :some_value }
50
- # instance
51
- working_instance = CascadingConfiguration::CompositingHash::Mock01sub1.new
52
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
53
- cascading_composite_hash.local_cascading_hash.should == {}
54
- cascading_composite_hash.should == { :some_setting => :some_value,
55
- :other_setting => :some_value,
56
- :yet_another_setting => :some_value }
57
- cascading_composite_hash[ :and_still_another_setting ] = :some_value
58
- cascading_composite_hash.local_cascading_hash.should == { :and_still_another_setting => :some_value }
59
- cascading_composite_hash.should == { :some_setting => :some_value,
60
- :other_setting => :some_value,
61
- :yet_another_setting => :some_value,
62
- :and_still_another_setting => :some_value }
63
- end
64
-
65
- ###########
66
- # store #
67
- ###########
68
-
69
- it 'can add elements' do
70
- # primary class
71
- class CascadingConfiguration::CompositingHash::Mock02
72
- include CascadingConfiguration::Variable
73
- include CascadingConfiguration::CompositingHash::Instance
74
- end
75
- working_instance = CascadingConfiguration::CompositingHash::Mock02
76
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
77
- cascading_composite_hash.store( :some_setting, :some_value )
78
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
79
- cascading_composite_hash.should == { :some_setting => :some_value }
80
- cascading_composite_hash.store( :other_setting, :some_value )
81
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
82
- :other_setting => :some_value }
83
- cascading_composite_hash.should == { :some_setting => :some_value,
84
- :other_setting => :some_value }
85
- # instance
86
- working_instance = CascadingConfiguration::CompositingHash::Mock02.new
87
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
88
- cascading_composite_hash.local_cascading_hash.should == {}
89
- cascading_composite_hash.should == { :some_setting => :some_value,
90
- :other_setting => :some_value }
91
- cascading_composite_hash.store( :another_setting, :some_value )
92
- cascading_composite_hash.local_cascading_hash.should == { :another_setting => :some_value }
93
- cascading_composite_hash.should == { :some_setting => :some_value,
94
- :other_setting => :some_value,
95
- :another_setting => :some_value }
96
- # inheriting class
97
- class CascadingConfiguration::CompositingHash::Mock02sub1 < CascadingConfiguration::CompositingHash::Mock02
98
- end
99
- working_instance = CascadingConfiguration::CompositingHash::Mock02sub1
100
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
101
- cascading_composite_hash.local_cascading_hash.should == {}
102
- cascading_composite_hash.should == { :some_setting => :some_value,
103
- :other_setting => :some_value }
104
- cascading_composite_hash.store( :yet_another_setting, :some_value )
105
- cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
106
- cascading_composite_hash.should == { :some_setting => :some_value,
107
- :other_setting => :some_value,
108
- :yet_another_setting => :some_value }
109
- # instance
110
- working_instance = CascadingConfiguration::CompositingHash::Mock02sub1.new
111
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
112
- cascading_composite_hash.local_cascading_hash.should == {}
113
- cascading_composite_hash.should == { :some_setting => :some_value,
114
- :other_setting => :some_value,
115
- :yet_another_setting => :some_value }
116
- cascading_composite_hash.store( :and_still_another_setting, :some_value )
117
- cascading_composite_hash.local_cascading_hash.should == { :and_still_another_setting => :some_value }
118
- cascading_composite_hash.should == { :some_setting => :some_value,
119
- :other_setting => :some_value,
120
- :yet_another_setting => :some_value,
121
- :and_still_another_setting => :some_value }
122
- end
123
-
124
- ############
125
- # delete #
126
- ############
127
-
128
- it 'can exclude elements' do
129
- # primary class
130
- class CascadingConfiguration::CompositingHash::Mock03
131
- include CascadingConfiguration::Variable
132
- include CascadingConfiguration::CompositingHash::Instance
133
- end
134
- working_instance = CascadingConfiguration::CompositingHash::Mock03
135
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
136
- cascading_composite_hash.store( :some_setting, :some_value )
137
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
138
- cascading_composite_hash.should == { :some_setting => :some_value }
139
- cascading_composite_hash.delete( :some_setting ).should == :some_value
140
- cascading_composite_hash.should == {}
141
- cascading_composite_hash.store( :other_setting, :some_value )
142
- cascading_composite_hash.local_cascading_hash.should == { :other_setting => :some_value }
143
- cascading_composite_hash.should == { :other_setting => :some_value }
144
- # instance
145
- working_instance = CascadingConfiguration::CompositingHash::Mock03.new
146
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
147
- cascading_composite_hash.local_cascading_hash.should == {}
148
- cascading_composite_hash.should == { :other_setting => :some_value }
149
- cascading_composite_hash.delete( :other_setting ).should == :some_value
150
- cascading_composite_hash.local_cascading_hash.should == {}
151
- cascading_composite_hash.local_cascading_hash.exclude_array.should == [ :other_setting ]
152
- cascading_composite_hash.should == {}
153
- # inheriting class
154
- class CascadingConfiguration::CompositingHash::Mock03sub1 < CascadingConfiguration::CompositingHash::Mock03
155
- end
156
- working_instance = CascadingConfiguration::CompositingHash::Mock03sub1
157
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
158
- cascading_composite_hash.local_cascading_hash.should == {}
159
- cascading_composite_hash.should == { :other_setting => :some_value }
160
- cascading_composite_hash.delete( :other_setting ).should == :some_value
161
- cascading_composite_hash.local_cascading_hash.should == {}
162
- cascading_composite_hash.local_cascading_hash.exclude_array.should == [ :other_setting ]
163
- cascading_composite_hash.should == {}
164
- # instance
165
- working_instance = CascadingConfiguration::CompositingHash::Mock03sub1.new
166
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
167
- cascading_composite_hash.local_cascading_hash.should == {}
168
- cascading_composite_hash.should == {}
169
- cascading_composite_hash.store( :and_still_another_setting, :some_value )
170
- cascading_composite_hash.local_cascading_hash.should == { :and_still_another_setting => :some_value }
171
- cascading_composite_hash.should == { :and_still_another_setting => :some_value }
172
- cascading_composite_hash.delete( :and_still_another_setting ).should == :some_value
173
- cascading_composite_hash.should == {}
174
- end
175
-
176
- ############
177
- # merge! #
178
- ############
179
-
180
- it 'can merge from another hash' do
181
- # primary class
182
- class CascadingConfiguration::CompositingHash::Mock04
183
- include CascadingConfiguration::Variable
184
- include CascadingConfiguration::CompositingHash::Instance
185
- end
186
- working_instance = CascadingConfiguration::CompositingHash::Mock04
187
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
188
- cascading_composite_hash.merge!( :some_setting => :some_value )
189
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
190
- cascading_composite_hash.should == { :some_setting => :some_value }
191
- cascading_composite_hash.merge!( :other_setting => :some_value )
192
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value,
193
- :other_setting => :some_value }
194
- cascading_composite_hash.should == { :some_setting => :some_value,
195
- :other_setting => :some_value }
196
- # instance
197
- working_instance = CascadingConfiguration::CompositingHash::Mock04.new
198
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
199
- cascading_composite_hash.local_cascading_hash.should == {}
200
- cascading_composite_hash.should == { :some_setting => :some_value,
201
- :other_setting => :some_value }
202
- cascading_composite_hash.merge!( :another_setting => :some_value )
203
- cascading_composite_hash.local_cascading_hash.should == { :another_setting => :some_value }
204
- cascading_composite_hash.should == { :some_setting => :some_value,
205
- :other_setting => :some_value,
206
- :another_setting => :some_value }
207
- # inheriting class
208
- class CascadingConfiguration::CompositingHash::Mock04sub1 < CascadingConfiguration::CompositingHash::Mock04
209
- end
210
- working_instance = CascadingConfiguration::CompositingHash::Mock04sub1
211
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
212
- cascading_composite_hash.local_cascading_hash.should == {}
213
- cascading_composite_hash.should == { :some_setting => :some_value,
214
- :other_setting => :some_value }
215
- cascading_composite_hash.merge!( :yet_another_setting => :some_value )
216
- cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
217
- cascading_composite_hash.should == { :some_setting => :some_value,
218
- :other_setting => :some_value,
219
- :yet_another_setting => :some_value }
220
- # instance
221
- working_instance = CascadingConfiguration::CompositingHash::Mock04sub1.new
222
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
223
- cascading_composite_hash.local_cascading_hash.should == {}
224
- cascading_composite_hash.should == { :some_setting => :some_value,
225
- :other_setting => :some_value,
226
- :yet_another_setting => :some_value }
227
- cascading_composite_hash.merge!( :and_still_another_setting => :some_value )
228
- cascading_composite_hash.local_cascading_hash.should == { :and_still_another_setting => :some_value }
229
- cascading_composite_hash.should == { :some_setting => :some_value,
230
- :other_setting => :some_value,
231
- :yet_another_setting => :some_value,
232
- :and_still_another_setting => :some_value }
233
- end
234
-
235
- #############
236
- # replace #
237
- #############
238
-
239
- it 'can replace existing elements with others' do
240
- # primary class
241
- class CascadingConfiguration::CompositingHash::Mock05
242
- include CascadingConfiguration::Variable
243
- include CascadingConfiguration::CompositingHash::Instance
244
- end
245
- working_instance = CascadingConfiguration::CompositingHash::Mock05
246
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
247
- cascading_composite_hash.replace( :some_setting => :some_value )
248
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
249
- cascading_composite_hash.should == { :some_setting => :some_value }
250
- cascading_composite_hash.replace( :other_setting => :some_value )
251
- cascading_composite_hash.local_cascading_hash.should == { :other_setting => :some_value }
252
- cascading_composite_hash.should == { :other_setting => :some_value }
253
- # instance
254
- working_instance = CascadingConfiguration::CompositingHash::Mock05.new
255
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
256
- cascading_composite_hash.local_cascading_hash.should == {}
257
- cascading_composite_hash.should == { :other_setting => :some_value }
258
- cascading_composite_hash.replace( :another_setting => :some_value )
259
- cascading_composite_hash.local_cascading_hash.should == { :another_setting => :some_value }
260
- cascading_composite_hash.should == { :another_setting => :some_value }
261
- # inheriting class
262
- class CascadingConfiguration::CompositingHash::Mock05sub1 < CascadingConfiguration::CompositingHash::Mock05
263
- end
264
- working_instance = CascadingConfiguration::CompositingHash::Mock05sub1
265
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
266
- cascading_composite_hash.local_cascading_hash.should == {}
267
- cascading_composite_hash.should == { :other_setting => :some_value }
268
- cascading_composite_hash.replace( :yet_another_setting => :some_value )
269
- cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
270
- cascading_composite_hash.should == { :yet_another_setting => :some_value }
271
- # instance
272
- working_instance = CascadingConfiguration::CompositingHash::Mock05sub1.new
273
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
274
- cascading_composite_hash.local_cascading_hash.should == {}
275
- cascading_composite_hash.should == { :yet_another_setting => :some_value }
276
- cascading_composite_hash.replace( :and_still_another_setting => :some_value )
277
- cascading_composite_hash.local_cascading_hash.should == { :and_still_another_setting => :some_value }
278
- cascading_composite_hash.should == { :and_still_another_setting => :some_value }
279
- end
280
-
281
- ###########
282
- # shift #
283
- ###########
284
-
285
- it 'can shift the first element' do
286
- # primary class
287
- class CascadingConfiguration::CompositingHash::Mock06
288
- include CascadingConfiguration::Variable
289
- include CascadingConfiguration::CompositingHash::Instance
290
- end
291
- working_instance = CascadingConfiguration::CompositingHash::Mock06
292
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
293
- cascading_composite_hash.replace( :some_setting => :some_value )
294
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
295
- cascading_composite_hash.should == { :some_setting => :some_value }
296
- cascading_composite_hash.shift.should == [ :some_setting, :some_value ]
297
- cascading_composite_hash.should == {}
298
- cascading_composite_hash.replace( :other_setting => :some_value )
299
- cascading_composite_hash.local_cascading_hash.should == { :other_setting => :some_value }
300
- cascading_composite_hash.should == { :other_setting => :some_value }
301
- cascading_composite_hash.shift.should == [ :other_setting, :some_value ]
302
- cascading_composite_hash.should == {}
303
- # instance
304
- working_instance = CascadingConfiguration::CompositingHash::Mock06.new
305
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
306
- cascading_composite_hash.local_cascading_hash.should == {}
307
- cascading_composite_hash.replace( :other_setting => :some_value )
308
- cascading_composite_hash.should == { :other_setting => :some_value }
309
- cascading_composite_hash.shift.should == [ :other_setting, :some_value ]
310
- cascading_composite_hash.should == {}
311
- cascading_composite_hash.replace( :another_setting => :some_value )
312
- cascading_composite_hash.local_cascading_hash.should == { :another_setting => :some_value }
313
- cascading_composite_hash.should == { :another_setting => :some_value }
314
- cascading_composite_hash.shift.should == [ :another_setting, :some_value ]
315
- cascading_composite_hash.should == {}
316
- # inheriting class
317
- class CascadingConfiguration::CompositingHash::Mock06sub1 < CascadingConfiguration::CompositingHash::Mock06
318
- end
319
- working_instance = CascadingConfiguration::CompositingHash::Mock06sub1
320
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
321
- cascading_composite_hash.local_cascading_hash.should == {}
322
- cascading_composite_hash.replace( :other_setting => :some_value )
323
- cascading_composite_hash.should == { :other_setting => :some_value }
324
- cascading_composite_hash.shift.should == [ :other_setting, :some_value ]
325
- cascading_composite_hash.should == {}
326
- cascading_composite_hash.replace( :yet_another_setting => :some_value )
327
- cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
328
- cascading_composite_hash.should == { :yet_another_setting => :some_value }
329
- cascading_composite_hash.shift.should == [ :yet_another_setting, :some_value ]
330
- cascading_composite_hash.should == {}
331
- # instance
332
- working_instance = CascadingConfiguration::CompositingHash::Mock06sub1.new
333
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
334
- cascading_composite_hash.local_cascading_hash.should == {}
335
- cascading_composite_hash.replace( :yet_another_setting => :some_value )
336
- cascading_composite_hash.should == { :yet_another_setting => :some_value }
337
- cascading_composite_hash.shift.should == [ :yet_another_setting, :some_value ]
338
- cascading_composite_hash.should == {}
339
- cascading_composite_hash.replace( :and_still_another_setting => :some_value )
340
- cascading_composite_hash.local_cascading_hash.should == { :and_still_another_setting => :some_value }
341
- cascading_composite_hash.should == { :and_still_another_setting => :some_value }
342
- cascading_composite_hash.shift.should == [ :and_still_another_setting, :some_value ]
343
- cascading_composite_hash.should == {}
344
- end
345
-
346
- ###########
347
- # clear #
348
- ###########
349
-
350
- it 'can clear, causing present elements to be excluded' do
351
- # primary class
352
- class CascadingConfiguration::CompositingHash::Mock07
353
- include CascadingConfiguration::Variable
354
- include CascadingConfiguration::CompositingHash::Instance
355
- end
356
- working_instance = CascadingConfiguration::CompositingHash::Mock07
357
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
358
- cascading_composite_hash.replace( :some_setting => :some_value )
359
- cascading_composite_hash.local_cascading_hash.should == { :some_setting => :some_value }
360
- cascading_composite_hash.should == { :some_setting => :some_value }
361
- cascading_composite_hash.clear
362
- cascading_composite_hash.should == {}
363
- cascading_composite_hash.replace( :other_setting => :some_value )
364
- cascading_composite_hash.local_cascading_hash.should == { :other_setting => :some_value }
365
- cascading_composite_hash.should == { :other_setting => :some_value }
366
- cascading_composite_hash.clear
367
- cascading_composite_hash.should == {}
368
- # instance
369
- working_instance = CascadingConfiguration::CompositingHash::Mock07.new
370
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
371
- cascading_composite_hash.local_cascading_hash.should == {}
372
- cascading_composite_hash.should == {}
373
- cascading_composite_hash.replace( :another_setting => :some_value )
374
- cascading_composite_hash.local_cascading_hash.should == { :another_setting => :some_value }
375
- cascading_composite_hash.should == { :another_setting => :some_value }
376
- cascading_composite_hash.clear
377
- cascading_composite_hash.should == {}
378
- # inheriting class
379
- class CascadingConfiguration::CompositingHash::Mock07sub1 < CascadingConfiguration::CompositingHash::Mock07
380
- end
381
- working_instance = CascadingConfiguration::CompositingHash::Mock07sub1
382
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
383
- cascading_composite_hash.local_cascading_hash.should == {}
384
- cascading_composite_hash.should == {}
385
- cascading_composite_hash.replace( :yet_another_setting => :some_value )
386
- cascading_composite_hash.local_cascading_hash.should == { :yet_another_setting => :some_value }
387
- cascading_composite_hash.should == { :yet_another_setting => :some_value }
388
- cascading_composite_hash.clear
389
- cascading_composite_hash.should == {}
390
- # instance
391
- working_instance = CascadingConfiguration::CompositingHash::Mock07sub1.new
392
- cascading_composite_hash = working_instance.composite_hash_for_cascading_configuration( :some_configuration )
393
- cascading_composite_hash.local_cascading_hash.should == {}
394
- cascading_composite_hash.should == {}
395
- cascading_composite_hash.replace( :and_still_another_setting => :some_value )
396
- cascading_composite_hash.local_cascading_hash.should == { :and_still_another_setting => :some_value }
397
- cascading_composite_hash.should == { :and_still_another_setting => :some_value }
398
- cascading_composite_hash.clear
399
- cascading_composite_hash.should == {}
400
- end
401
-
402
- end
@@ -1,95 +0,0 @@
1
-
2
- require_relative '../../lib/cascading-configuration-hash.rb'
3
-
4
- describe CascadingConfiguration::LocalConfigurationHash do
5
-
6
- #########
7
- # []= #
8
- #########
9
-
10
- it 'can add elements' do
11
- hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
12
- hash_instance[ :some_setting ] = :some_value
13
- hash_instance.should == { :some_setting => :some_value }
14
- hash_instance.exclude_array.include?( :some_setting ).should == false
15
- hash_instance[ :other_setting ] = :some_value
16
- hash_instance.should == { :some_setting => :some_value,
17
- :other_setting => :some_value }
18
- hash_instance.exclude_array.include?( :other_setting ).should == false
19
- end
20
-
21
- ###########
22
- # store #
23
- ###########
24
-
25
- it 'can add elements' do
26
- hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
27
- hash_instance.store( :some_setting, :some_value )
28
- hash_instance.should == { :some_setting => :some_value }
29
- hash_instance.exclude_array.include?( :some_setting ).should == false
30
- hash_instance.store( :other_setting, :some_value )
31
- hash_instance.should == { :some_setting => :some_value,
32
- :other_setting => :some_value }
33
- hash_instance.exclude_array.include?( :other_setting ).should == false
34
- end
35
-
36
- ############
37
- # delete #
38
- ############
39
-
40
- it 'can exclude elements' do
41
- hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
42
- hash_instance[ :some_setting ] = :some_value
43
- hash_instance.delete( :some_setting ).should == :some_value
44
- hash_instance.should == {}
45
- hash_instance.exclude_array.include?( :some_setting ).should == true
46
- end
47
-
48
- ############
49
- # merge! #
50
- ############
51
-
52
- it 'can merge from another hash' do
53
- hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
54
- hash_instance.merge!( { :some_setting => :some_value } )
55
- hash_instance.should == { :some_setting => :some_value }
56
- end
57
-
58
- #############
59
- # replace #
60
- #############
61
-
62
- it 'can replace existing elements with others' do
63
- hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
64
- hash_instance.merge!( { :some_setting => :some_value } )
65
- hash_instance.should == { :some_setting => :some_value }
66
- hash_instance.replace( { :other_setting => :some_value } )
67
- hash_instance.should == { :other_setting => :some_value }
68
- hash_instance.exclude_array.include?( :other_setting ).should == false
69
- hash_instance.exclude_array.include?( :some_setting ).should == true
70
- end
71
-
72
- ###########
73
- # shift #
74
- ###########
75
-
76
- it 'can shift the first element' do
77
- hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
78
- hash_instance.merge!( { :some_setting => :some_value } )
79
- hash_instance.shift.should == [ :some_setting, :some_value ]
80
- hash_instance.should == {}
81
- end
82
-
83
- ###########
84
- # clear #
85
- ###########
86
-
87
- it 'can clear, causing present elements to be excluded' do
88
- hash_instance = ::CascadingConfiguration::LocalConfigurationHash.new
89
- hash_instance.merge!( { :some_setting => :some_value } )
90
- hash_instance.clear
91
- hash_instance.should == {}
92
- hash_instance.exclude_array.include?( :some_setting ).should == true
93
- end
94
-
95
- end
@@ -1,28 +0,0 @@
1
-
2
- require_relative '../../../lib/cascading-configuration-hash.rb'
3
-
4
- describe CascadingConfiguration::Hash::Accessors do
5
-
6
- ######################################
7
- # define_configuration_hash_setter #
8
- # define_configuration_hash_getter #
9
- ######################################
10
-
11
- it 'can define a method to get and modify the configuration hash' do
12
- class CascadingConfiguration::Hash::Mock
13
- include CascadingConfiguration::Variable
14
- extend CascadingConfiguration::Hash::Accessors
15
- include CascadingConfiguration::Hash::ObjectInstance
16
- extend CascadingConfiguration::Hash::ClassInstance
17
- end
18
- # setter
19
- CascadingConfiguration::Hash::Mock.define_configuration_hash_setter( :some_configuration )
20
- CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration= ).should == true
21
- CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration= ).should == true
22
- # getter
23
- CascadingConfiguration::Hash::Mock.define_configuration_hash_getter( :some_configuration )
24
- CascadingConfiguration::Hash::Mock.methods.include?( :some_configuration ).should == true
25
- CascadingConfiguration::Hash::Mock.instance_methods.include?( :some_configuration ).should == true
26
- end
27
-
28
- end