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