cascading_configuration 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/CHANGELOG.md +40 -0
  2. data/README.md +211 -0
  3. data/lib/cascading_configuration/array/sorted/unique.rb +110 -0
  4. data/lib/cascading_configuration/array/sorted.rb +106 -0
  5. data/lib/cascading_configuration/array/unique.rb +106 -0
  6. data/lib/cascading_configuration/array.rb +103 -0
  7. data/lib/cascading_configuration/core/enable_instance_support.rb +22 -0
  8. data/lib/cascading_configuration/core/enable_module_support.rb +24 -0
  9. data/lib/cascading_configuration/core/encapsulation.rb +343 -0
  10. data/lib/cascading_configuration/core/instance_controller/extension_module.rb +38 -0
  11. data/lib/cascading_configuration/core/instance_controller/support_module/instance_support_module.rb +21 -0
  12. data/lib/cascading_configuration/core/instance_controller/support_module/singleton_support_module.rb +21 -0
  13. data/lib/cascading_configuration/core/instance_controller/support_module.rb +253 -0
  14. data/lib/cascading_configuration/core/instance_controller.rb +840 -0
  15. data/lib/cascading_configuration/core/module/block_configurations/cascading_variables.rb +129 -0
  16. data/lib/cascading_configuration/core/module/block_configurations.rb +15 -0
  17. data/lib/cascading_configuration/core/module/extended_configurations/compositing_objects.rb +173 -0
  18. data/lib/cascading_configuration/core/module/extended_configurations.rb +65 -0
  19. data/lib/cascading_configuration/core/module/inheriting_values.rb +64 -0
  20. data/lib/cascading_configuration/core/module.rb +284 -0
  21. data/lib/cascading_configuration/core.rb +23 -0
  22. data/lib/cascading_configuration/hash.rb +103 -0
  23. data/lib/cascading_configuration/setting.rb +87 -0
  24. data/lib/cascading_configuration.rb +47 -0
  25. data/lib/namespaces.rb +9 -0
  26. data/lib/requires.rb +46 -0
  27. data/spec/cascading_configuration/array/sorted/unique_spec.rb +742 -0
  28. data/spec/cascading_configuration/array/sorted_spec.rb +741 -0
  29. data/spec/cascading_configuration/array/unique_spec.rb +746 -0
  30. data/spec/cascading_configuration/array_spec.rb +768 -0
  31. data/spec/cascading_configuration/core/encapsulation_spec.rb +208 -0
  32. data/spec/cascading_configuration/core/instance_controller/extension_module_spec.rb +26 -0
  33. data/spec/cascading_configuration/core/instance_controller/support_module_spec.rb +269 -0
  34. data/spec/cascading_configuration/core/instance_controller_spec.rb +273 -0
  35. data/spec/cascading_configuration/core/module/block_configurations/cascading_variables_spec.rb +17 -0
  36. data/spec/cascading_configuration/core/module/extended_configurations/compositing_objects_spec.rb +127 -0
  37. data/spec/cascading_configuration/core/module/extended_configurations_spec.rb +37 -0
  38. data/spec/cascading_configuration/core/module/inheriting_values_spec.rb +87 -0
  39. data/spec/cascading_configuration/core/module_spec.rb +491 -0
  40. data/spec/cascading_configuration/hash_spec.rb +826 -0
  41. data/spec/cascading_configuration/setting_spec.rb +687 -0
  42. data/spec/cascading_configuration_spec.rb +58 -0
  43. metadata +185 -0
@@ -0,0 +1,742 @@
1
+
2
+ require_relative '../../../../lib/cascading_configuration.rb'
3
+
4
+ describe CascadingConfiguration::Array::Sorted::Unique do
5
+
6
+ ##############################
7
+ # attr_sorted_unique_array #
8
+ ##############################
9
+
10
+ it 'can define a configuration array, which is the primary interface' do
11
+
12
+ # possibilities:
13
+ # * module extended with setting
14
+ # => singleton gets attr_setting and configurations
15
+ # => including modules and classes get nothing
16
+ # => extending modules and classes get nothing
17
+ # => instances of including and extending classes get nothing
18
+ # * module included with setting
19
+ # => singleton gets attr_setting and configurations
20
+ # => including modules and classes get attr_setting and configurations
21
+ # => instances of including classes get configurations
22
+ # => extending modules and classes get attr_setting and configurations
23
+ # => instances of extending classes get nothing
24
+ module ::CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleExtended
25
+ extend CascadingConfiguration::Array::Sorted::Unique
26
+ # => singleton gets attr_setting and configurations
27
+ respond_to?( :attr_sorted_unique_array ).should == true
28
+ respond_to?( :attr_configuration_sorted_unique_array ).should == true
29
+ attr_sorted_unique_array :configuration_setting
30
+ respond_to?( :configuration_setting ).should == true
31
+ configuration_setting.should == []
32
+ configuration_setting.push( :a_configuration )
33
+ configuration_setting.should == [ :a_configuration ]
34
+ method_defined?( :configuration_setting ).should == false
35
+ instance_variables.empty?.should == true
36
+ # => including modules and classes get nothing
37
+ module SubmoduleIncluding
38
+ include CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleExtended
39
+ method_defined?( :configuration_setting ).should == false
40
+ respond_to?( :configuration_setting ).should == false
41
+ instance_variables.empty?.should == true
42
+ end
43
+ # => extending modules and classes get nothing
44
+ module SubmoduleExtending
45
+ extend CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleExtended
46
+ method_defined?( :configuration_setting ).should == false
47
+ respond_to?( :configuration_setting ).should == false
48
+ instance_variables.empty?.should == true
49
+ end
50
+ # => instances of including and extending classes get nothing
51
+ class ClassIncluding
52
+ include CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleExtended
53
+ method_defined?( :configuration_setting ).should == false
54
+ respond_to?( :configuration_setting ).should == false
55
+ instance_variables.empty?.should == true
56
+ end
57
+ class ClassExtending
58
+ extend CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleExtended
59
+ method_defined?( :configuration_setting ).should == false
60
+ respond_to?( :configuration_setting ).should == false
61
+ instance_variables.empty?.should == true
62
+ end
63
+ end
64
+
65
+ # * module included with setting
66
+ module ::CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleIncluded
67
+ include CascadingConfiguration::Array::Sorted::Unique
68
+ # => singleton gets attr_setting and configurations
69
+ respond_to?( :attr_sorted_unique_array ).should == true
70
+ attr_sorted_unique_array :configuration_setting
71
+ respond_to?( :configuration_setting ).should == true
72
+ configuration_setting.should == []
73
+ configuration_setting.push( :a_configuration )
74
+ configuration_setting.should == [ :a_configuration ]
75
+ method_defined?( :configuration_setting ).should == true
76
+ instance_variables.empty?.should == true
77
+ # => including modules and classes get attr_setting and configurations
78
+ module SubmoduleIncluding
79
+ include CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleIncluded
80
+ method_defined?( :configuration_setting ).should == true
81
+ respond_to?( :configuration_setting ).should == true
82
+ configuration_setting.should == [ :a_configuration ]
83
+ configuration_setting.push( :another_configuration )
84
+ configuration_setting.should == [ :a_configuration, :another_configuration ]
85
+ instance_variables.empty?.should == true
86
+ end
87
+ # => extending modules and classes get attr_setting and configurations
88
+ module SubmoduleExtending
89
+ extend CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleIncluded
90
+ # if we're extended then we want to use the eigenclass ancestor chain
91
+ # - the first ancestor will be the extending module
92
+ # - the rest of the ancestors will be the extending module's include chain
93
+ respond_to?( :configuration_setting ).should == true
94
+ configuration_setting.should == [ :a_configuration ]
95
+ configuration_setting.push( :some_other_configuration )
96
+ configuration_setting.should == [ :a_configuration, :some_other_configuration ]
97
+ method_defined?( :configuration_setting ).should == false
98
+ instance_variables.empty?.should == true
99
+ end
100
+ # => instances of including classes get configurations
101
+ class ClassIncluding
102
+ include CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleIncluded
103
+ method_defined?( :configuration_setting ).should == true
104
+ respond_to?( :configuration_setting ).should == true
105
+ configuration_setting.should == [ :a_configuration ]
106
+ configuration_setting.push( :some_other_configuration )
107
+ configuration_setting.should == [ :a_configuration, :some_other_configuration ]
108
+ instance_variables.empty?.should == true
109
+ end
110
+ setting_class_including_instance = ClassIncluding.new
111
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == true
112
+ setting_class_including_instance.configuration_setting.should == [ :a_configuration, :some_other_configuration ]
113
+ setting_class_including_instance.configuration_setting.delete( :some_other_configuration )
114
+ setting_class_including_instance.configuration_setting = [ :our_setting_value ]
115
+ setting_class_including_instance.configuration_setting.should == [ :our_setting_value ]
116
+ setting_class_including_instance.instance_variables.empty?.should == true
117
+ # => instances of extending classes get nothing
118
+ class ClassExtending
119
+ extend CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleIncluded
120
+ respond_to?( :configuration_setting ).should == true
121
+ configuration_setting.should == [ :a_configuration ]
122
+ configuration_setting.push( :some_other_configuration )
123
+ configuration_setting.should == [ :a_configuration, :some_other_configuration ]
124
+ instance_variables.empty?.should == true
125
+ end
126
+ setting_class_including_instance = ClassExtending.new
127
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
128
+ setting_class_including_instance.instance_variables.empty?.should == true
129
+ end
130
+
131
+ class CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass
132
+ include CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockModuleIncluded::SubmoduleIncluding
133
+ configuration_setting.should == [ :a_configuration, :another_configuration ]
134
+ configuration_setting.push( :some_other_configuration )
135
+ configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
136
+ instance_variables.empty?.should == true
137
+ end
138
+ object_instance_one = CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass.new
139
+ object_instance_one.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
140
+ object_instance_one.configuration_setting.delete( :a_configuration )
141
+ object_instance_one.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
142
+ object_instance_one.instance_variables.empty?.should == true
143
+ class CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass
144
+ configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
145
+ configuration_setting.delete( :a_configuration )
146
+ configuration_setting.should == [ :another_configuration, :some_other_configuration ]
147
+ instance_variables.empty?.should == true
148
+ end
149
+ object_instance_two = CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub1.new
150
+ object_instance_two.configuration_setting.should == [ :another_configuration, :some_other_configuration ]
151
+ object_instance_two.configuration_setting.delete( :another_configuration )
152
+ object_instance_two.configuration_setting.should == [ :some_other_configuration ]
153
+ object_instance_two.instance_variables.empty?.should == true
154
+ class CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub1
155
+ configuration_setting.should == [ :another_configuration, :some_other_configuration ]
156
+ configuration_setting.push( :yet_another_configuration )
157
+ configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
158
+ instance_variables.empty?.should == true
159
+ end
160
+
161
+ # change ancestor setting
162
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
163
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
164
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
165
+ object_instance_one.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
166
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
167
+ object_instance_two.configuration_setting.should == [ :a_yet_unused_configuration, :some_other_configuration ]
168
+
169
+ # freeze ancestor setting
170
+ object_instance_one.configuration_setting.freeze!
171
+ object_instance_one.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
172
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub1.configuration_setting.freeze!
173
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
174
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
175
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :non_cascading_configuration, :some_other_configuration ]
176
+ object_instance_one.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
177
+ CascadingConfiguration::Array::Sorted::Unique::ConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
178
+ object_instance_two.configuration_setting.should == [ :a_yet_unused_configuration, :some_other_configuration ]
179
+
180
+ end
181
+
182
+ #####################################
183
+ # attr_module_sorted_unique_array #
184
+ # attr_class_sorted_unique_array #
185
+ #####################################
186
+
187
+ it 'can define a class configuration array, which will not cascade to instances' do
188
+
189
+ # possibilities:
190
+ # * module extended with setting
191
+ # => singleton gets attr_setting and configurations
192
+ # => including modules and classes get nothing
193
+ # => extending modules and classes get nothing
194
+ # => instances of including and extending classes get nothing
195
+ # * module included with setting
196
+ # => singleton gets attr_setting and configurations
197
+ # => including modules and classes get attr_setting and configurations
198
+ # => instances of including classes get configurations
199
+ # => extending modules and classes get attr_setting and configurations
200
+ # => instances of extending classes get nothing
201
+ module ::CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleExtended
202
+ extend CascadingConfiguration::Array::Sorted::Unique
203
+ # => singleton gets attr_setting and configurations
204
+ respond_to?( :attr_module_configuration_sorted_unique_array ).should == true
205
+ respond_to?( :attr_module_sorted_unique_array ).should == true
206
+ method( :attr_module_sorted_unique_array ).should == method( :attr_class_sorted_unique_array )
207
+ attr_module_sorted_unique_array :configuration_setting
208
+ respond_to?( :configuration_setting ).should == true
209
+ configuration_setting.should == []
210
+ configuration_setting.push( :a_configuration )
211
+ configuration_setting.should == [ :a_configuration ]
212
+ method_defined?( :configuration_setting ).should == false
213
+ instance_variables.empty?.should == true
214
+ # => including modules and classes get nothing
215
+ module SubmoduleIncluding
216
+ include CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleExtended
217
+ method_defined?( :configuration_setting ).should == false
218
+ respond_to?( :configuration_setting ).should == false
219
+ instance_variables.empty?.should == true
220
+ end
221
+ # => extending modules and classes get nothing
222
+ module SubmoduleExtending
223
+ extend CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleExtended
224
+ method_defined?( :configuration_setting ).should == false
225
+ respond_to?( :configuration_setting ).should == false
226
+ instance_variables.empty?.should == true
227
+ end
228
+ # => instances of including and extending classes get nothing
229
+ class ClassIncluding
230
+ include CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleExtended
231
+ method_defined?( :configuration_setting ).should == false
232
+ respond_to?( :configuration_setting ).should == false
233
+ instance_variables.empty?.should == true
234
+ end
235
+ class ClassExtending
236
+ extend CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleExtended
237
+ method_defined?( :configuration_setting ).should == false
238
+ respond_to?( :configuration_setting ).should == false
239
+ instance_variables.empty?.should == true
240
+ end
241
+ end
242
+
243
+ # * module included with setting
244
+ module ::CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleIncluded
245
+ include CascadingConfiguration::Array::Sorted::Unique
246
+ # => singleton gets attr_setting and configurations
247
+ respond_to?( :attr_module_sorted_unique_array ).should == true
248
+ attr_module_sorted_unique_array :configuration_setting
249
+ respond_to?( :configuration_setting ).should == true
250
+ configuration_setting.should == []
251
+ configuration_setting.push( :a_configuration )
252
+ configuration_setting.should == [ :a_configuration ]
253
+ method_defined?( :configuration_setting ).should == false
254
+ instance_variables.empty?.should == true
255
+ # => including modules and classes get attr_setting and configurations
256
+ module SubmoduleIncluding
257
+ include CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleIncluded
258
+ method_defined?( :configuration_setting ).should == false
259
+ respond_to?( :configuration_setting ).should == true
260
+ configuration_setting.should == [ :a_configuration ]
261
+ configuration_setting.push( :another_configuration )
262
+ configuration_setting.should == [ :a_configuration, :another_configuration ]
263
+ method_defined?( :configuration_setting ).should == false
264
+ instance_variables.empty?.should == true
265
+ end
266
+ # => extending modules and classes get attr_setting and configurations
267
+ module SubmoduleExtending
268
+ extend CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleIncluded
269
+ # if we're extended then we want to use the eigenclass ancestor chain
270
+ # - the first ancestor will be the extending module
271
+ # - the rest of the ancestors will be the extending module's include chain
272
+ respond_to?( :configuration_setting ).should == false
273
+ method_defined?( :configuration_setting ).should == false
274
+ instance_variables.empty?.should == true
275
+ end
276
+ # => instances of including classes get configurations
277
+ class ClassIncluding
278
+ include CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleIncluded
279
+ method_defined?( :configuration_setting ).should == false
280
+ respond_to?( :configuration_setting ).should == true
281
+ configuration_setting.should == [ :a_configuration ]
282
+ configuration_setting.push( :some_other_configuration )
283
+ configuration_setting.should == [ :a_configuration, :some_other_configuration ]
284
+ instance_variables.empty?.should == true
285
+ end
286
+ setting_class_including_instance = ClassIncluding.new
287
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
288
+ setting_class_including_instance.instance_variables.empty?.should == true
289
+ # => instances of extending classes get nothing
290
+ class ClassExtending
291
+ extend CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleIncluded
292
+ method_defined?( :configuration_setting ).should == false
293
+ respond_to?( :configuration_setting ).should == false
294
+ instance_variables.empty?.should == true
295
+ end
296
+ setting_class_including_instance = ClassExtending.new
297
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
298
+ setting_class_including_instance.instance_variables.empty?.should == true
299
+ end
300
+
301
+ class CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass
302
+ include CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockModuleIncluded::SubmoduleIncluding
303
+ method_defined?( :configuration_setting ).should == false
304
+ configuration_setting.should == [ :a_configuration, :another_configuration ]
305
+ configuration_setting.push( :some_other_configuration )
306
+ configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
307
+ instance_variables.empty?.should == true
308
+ end
309
+ object_instance_one = CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass.new
310
+ object_instance_one.respond_to?( :configuration_setting ).should == false
311
+ object_instance_one.instance_variables.empty?.should == true
312
+ class CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass
313
+ method_defined?( :configuration_setting ).should == false
314
+ configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
315
+ configuration_setting.delete( :a_configuration )
316
+ configuration_setting.should == [ :another_configuration, :some_other_configuration ]
317
+ instance_variables.empty?.should == true
318
+ end
319
+ object_instance_two = CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub1.new
320
+ object_instance_two.respond_to?( :configuration_setting ).should == false
321
+ object_instance_two.instance_variables.empty?.should == true
322
+ class CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub1
323
+ method_defined?( :configuration_setting ).should == false
324
+ configuration_setting.should == [ :another_configuration, :some_other_configuration ]
325
+ configuration_setting.push( :yet_another_configuration )
326
+ configuration_setting.should == [ :another_configuration, :some_other_configuration, :yet_another_configuration ]
327
+ instance_variables.empty?.should == true
328
+ end
329
+
330
+ # change ancestor setting
331
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
332
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
333
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
334
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
335
+
336
+ # freeze ancestor setting
337
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub1.configuration_setting.freeze!
338
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
339
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
340
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :non_cascading_configuration, :some_other_configuration ]
341
+ CascadingConfiguration::Array::Sorted::Unique::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
342
+
343
+ end
344
+
345
+ ####################################
346
+ # attr_local_sorted_unique_array #
347
+ ####################################
348
+
349
+ it 'can define a local configuration array, which will not cascade' do
350
+
351
+ # possibilities:
352
+ # * module extended with setting
353
+ # => singleton gets attr_setting and configurations
354
+ # => including modules and classes get nothing
355
+ # => extending modules and classes get nothing
356
+ # => instances of including and extending classes get nothing
357
+ # * module included with setting
358
+ # => singleton gets attr_setting and configurations
359
+ # => including modules and classes get attr_setting and configurations
360
+ # => instances of including classes get configurations
361
+ # => extending modules and classes get attr_setting and configurations
362
+ # => instances of extending classes get nothing
363
+ module ::CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleExtended
364
+ extend CascadingConfiguration::Array::Sorted::Unique
365
+ # => singleton gets attr_setting and configurations
366
+ respond_to?( :attr_local_configuration_sorted_unique_array ).should == true
367
+ respond_to?( :attr_local_sorted_unique_array ).should == true
368
+ attr_local_sorted_unique_array :configuration_setting
369
+ respond_to?( :configuration_setting ).should == true
370
+ configuration_setting.should == []
371
+ configuration_setting.push( :a_configuration )
372
+ configuration_setting.should == [ :a_configuration ]
373
+ method_defined?( :configuration_setting ).should == false
374
+ instance_variables.empty?.should == true
375
+ # => including modules and classes get nothing
376
+ module SubmoduleIncluding
377
+ include CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleExtended
378
+ method_defined?( :configuration_setting ).should == false
379
+ respond_to?( :configuration_setting ).should == false
380
+ instance_variables.empty?.should == true
381
+ end
382
+ # => extending modules and classes get nothing
383
+ module SubmoduleExtending
384
+ extend CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleExtended
385
+ method_defined?( :configuration_setting ).should == false
386
+ respond_to?( :configuration_setting ).should == false
387
+ instance_variables.empty?.should == true
388
+ end
389
+ # => instances of including and extending classes get nothing
390
+ class ClassIncluding
391
+ include CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleExtended
392
+ method_defined?( :configuration_setting ).should == false
393
+ respond_to?( :configuration_setting ).should == false
394
+ instance_variables.empty?.should == true
395
+ end
396
+ class ClassExtending
397
+ extend CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleExtended
398
+ method_defined?( :configuration_setting ).should == false
399
+ respond_to?( :configuration_setting ).should == false
400
+ instance_variables.empty?.should == true
401
+ end
402
+ end
403
+
404
+ # * module included with setting
405
+ module ::CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleIncluded
406
+ include CascadingConfiguration::Array::Sorted::Unique
407
+ # => singleton gets attr_setting and configurations
408
+ respond_to?( :attr_local_sorted_unique_array ).should == true
409
+ attr_local_sorted_unique_array :configuration_setting
410
+ respond_to?( :configuration_setting ).should == true
411
+ configuration_setting.should == []
412
+ configuration_setting.push( :a_configuration )
413
+ configuration_setting.should == [ :a_configuration ]
414
+ method_defined?( :configuration_setting ).should == true
415
+ instance_variables.empty?.should == true
416
+ # => including modules and classes get attr_setting and configurations
417
+ module SubmoduleIncluding
418
+ include CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleIncluded
419
+ method_defined?( :configuration_setting ).should == true
420
+ respond_to?( :configuration_setting ).should == false
421
+ instance_variables.empty?.should == true
422
+ end
423
+ # => extending modules and classes get attr_setting and configurations
424
+ module SubmoduleExtending
425
+ extend CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleIncluded
426
+ # if we're extended then we want to use the eigenclass ancestor chain
427
+ # - the first ancestor will be the extending module
428
+ # - the rest of the ancestors will be the extending module's include chain
429
+ respond_to?( :configuration_setting ).should == true
430
+ method_defined?( :configuration_setting ).should == false
431
+ instance_variables.empty?.should == true
432
+ end
433
+ # => instances of including classes get configurations
434
+ class ClassIncluding
435
+ include CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleIncluded
436
+ method_defined?( :configuration_setting ).should == true
437
+ respond_to?( :configuration_setting ).should == false
438
+ instance_variables.empty?.should == true
439
+ end
440
+ setting_class_including_instance = ClassIncluding.new
441
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == true
442
+ setting_class_including_instance.instance_variables.empty?.should == true
443
+ # => instances of extending classes get nothing
444
+ class ClassExtending
445
+ extend CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleIncluded
446
+ method_defined?( :configuration_setting ).should == false
447
+ respond_to?( :configuration_setting ).should == true
448
+ instance_variables.empty?.should == true
449
+ end
450
+ setting_class_including_instance = ClassExtending.new
451
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
452
+ setting_class_including_instance.instance_variables.empty?.should == true
453
+ end
454
+
455
+ class CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockClass
456
+ include CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockModuleIncluded::SubmoduleIncluding
457
+ method_defined?( :configuration_setting ).should == true
458
+ respond_to?( :configuration_setting ).should == false
459
+ instance_variables.empty?.should == true
460
+ end
461
+ object_instance_one = CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockClass.new
462
+ object_instance_one.respond_to?( :configuration_setting ).should == true
463
+ object_instance_one.instance_variables.empty?.should == true
464
+ class CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockClass
465
+ method_defined?( :configuration_setting ).should == true
466
+ respond_to?( :configuration_setting ).should == false
467
+ instance_variables.empty?.should == true
468
+ end
469
+ object_instance_two = CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockClassSub1.new
470
+ object_instance_two.respond_to?( :configuration_setting ).should == true
471
+ object_instance_two.instance_variables.empty?.should == true
472
+ class CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::Unique::LocalConfigurationMockClassSub1
473
+ method_defined?( :configuration_setting ).should == true
474
+ respond_to?( :configuration_setting ).should == false
475
+ instance_variables.empty?.should == true
476
+ end
477
+
478
+ end
479
+
480
+ #######################################
481
+ # attr_instance_sorted_unique_array #
482
+ #######################################
483
+
484
+ it 'can define an instance configuration array, which will not cascade' do
485
+
486
+ # possibilities:
487
+ # * module extended with setting
488
+ # => singleton gets attr_setting and configurations
489
+ # => including modules and classes get nothing
490
+ # => extending modules and classes get nothing
491
+ # => instances of including and extending classes get nothing
492
+ # * module included with setting
493
+ # => singleton gets attr_setting and configurations
494
+ # => including modules and classes get attr_setting and configurations
495
+ # => instances of including classes get configurations
496
+ # => extending modules and classes get attr_setting and configurations
497
+ # => instances of extending classes get nothing
498
+ module ::CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleExtended
499
+ extend CascadingConfiguration::Array::Sorted::Unique
500
+ # => singleton gets attr_setting and configurations
501
+ instance_variables.empty?.should == true
502
+ # => including modules and classes get nothing
503
+ module SubmoduleIncluding
504
+ include CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleExtended
505
+ method_defined?( :configuration_setting ).should == false
506
+ respond_to?( :configuration_setting ).should == false
507
+ instance_variables.empty?.should == true
508
+ end
509
+ # => extending modules and classes get nothing
510
+ module SubmoduleExtending
511
+ extend CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleExtended
512
+ method_defined?( :configuration_setting ).should == false
513
+ respond_to?( :configuration_setting ).should == false
514
+ instance_variables.empty?.should == true
515
+ end
516
+ # => instances of including and extending classes get nothing
517
+ class ClassIncluding
518
+ include CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleExtended
519
+ method_defined?( :configuration_setting ).should == false
520
+ respond_to?( :configuration_setting ).should == false
521
+ instance_variables.empty?.should == true
522
+ end
523
+ class ClassExtending
524
+ extend CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleExtended
525
+ method_defined?( :configuration_setting ).should == false
526
+ respond_to?( :configuration_setting ).should == false
527
+ instance_variables.empty?.should == true
528
+ end
529
+ end
530
+
531
+ # * module included with setting
532
+ module ::CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleIncluded
533
+ include CascadingConfiguration::Array::Sorted::Unique
534
+ # => singleton gets attr_setting and configurations
535
+ respond_to?( :attr_instance_sorted_unique_array ).should == true
536
+ attr_instance_sorted_unique_array :configuration_setting
537
+ respond_to?( :configuration_setting ).should == false
538
+ method_defined?( :configuration_setting ).should == true
539
+ instance_variables.empty?.should == true
540
+ # => including modules and classes get attr_setting and configurations
541
+ module SubmoduleIncluding
542
+ include CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleIncluded
543
+ method_defined?( :configuration_setting ).should == true
544
+ respond_to?( :configuration_setting ).should == false
545
+ method_defined?( :configuration_setting ).should == true
546
+ instance_variables.empty?.should == true
547
+ end
548
+ # => extending modules and classes get attr_setting and configurations
549
+ module SubmoduleExtending
550
+ extend CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleIncluded
551
+ # if we're extended then we want to use the eigenclass ancestor chain
552
+ # - the first ancestor will be the extending module
553
+ # - the rest of the ancestors will be the extending module's include chain
554
+ respond_to?( :configuration_setting ).should == true
555
+ method_defined?( :configuration_setting ).should == false
556
+ instance_variables.empty?.should == true
557
+ end
558
+ # => instances of including classes get configurations
559
+ class ClassIncluding
560
+ include CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleIncluded
561
+ method_defined?( :configuration_setting ).should == true
562
+ respond_to?( :configuration_setting ).should == false
563
+ instance_variables.empty?.should == true
564
+ end
565
+ setting_class_including_instance = ClassIncluding.new
566
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == true
567
+ setting_class_including_instance.instance_variables.empty?.should == true
568
+ # => instances of extending classes get nothing
569
+ class ClassExtending
570
+ extend CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleIncluded
571
+ method_defined?( :configuration_setting ).should == false
572
+ respond_to?( :configuration_setting ).should == true
573
+ instance_variables.empty?.should == true
574
+ end
575
+ setting_class_including_instance = ClassExtending.new
576
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
577
+ setting_class_including_instance.instance_variables.empty?.should == true
578
+ end
579
+
580
+ class CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockClass
581
+ include CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockModuleIncluded::SubmoduleIncluding
582
+ method_defined?( :configuration_setting ).should == true
583
+ respond_to?( :configuration_setting ).should == false
584
+ instance_variables.empty?.should == true
585
+ end
586
+ object_instance_one = CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockClass.new
587
+ object_instance_one.respond_to?( :configuration_setting ).should == true
588
+ object_instance_one.instance_variables.empty?.should == true
589
+ class CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockClass
590
+ method_defined?( :configuration_setting ).should == true
591
+ respond_to?( :configuration_setting ).should == false
592
+ instance_variables.empty?.should == true
593
+ end
594
+ object_instance_two = CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockClassSub1.new
595
+ object_instance_two.respond_to?( :configuration_setting ).should == true
596
+ object_instance_two.instance_variables.empty?.should == true
597
+ class CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::Unique::InstanceConfigurationMockClassSub1
598
+ method_defined?( :configuration_setting ).should == true
599
+ respond_to?( :configuration_setting ).should == false
600
+ instance_variables.empty?.should == true
601
+ end
602
+
603
+ end
604
+
605
+
606
+ #####################################
607
+ # attr_object_sorted_unique_array #
608
+ #####################################
609
+
610
+ it 'can define an object configuration array, which will not cascade' do
611
+
612
+ # possibilities:
613
+ # * module extended with setting
614
+ # => singleton gets attr_setting and configurations
615
+ # => including modules and classes get nothing
616
+ # => extending modules and classes get nothing
617
+ # => instances of including and extending classes get nothing
618
+ # * module included with setting
619
+ # => singleton gets attr_setting and configurations
620
+ # => including modules and classes get attr_setting and configurations
621
+ # => instances of including classes get configurations
622
+ # => extending modules and classes get attr_setting and configurations
623
+ # => instances of extending classes get nothing
624
+ module ::CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleExtended
625
+ extend CascadingConfiguration::Array::Sorted::Unique
626
+ # => singleton gets attr_setting and configurations
627
+ respond_to?( :attr_object_configuration_sorted_unique_array ).should == true
628
+ respond_to?( :attr_object_sorted_unique_array ).should == true
629
+ attr_object_sorted_unique_array :configuration_setting
630
+ respond_to?( :configuration_setting ).should == true
631
+ configuration_setting.should == []
632
+ configuration_setting.push( :a_configuration )
633
+ configuration_setting.should == [ :a_configuration ]
634
+ method_defined?( :configuration_setting ).should == false
635
+ instance_variables.empty?.should == true
636
+ # => including modules and classes get nothing
637
+ module SubmoduleIncluding
638
+ include CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleExtended
639
+ method_defined?( :configuration_setting ).should == false
640
+ respond_to?( :configuration_setting ).should == false
641
+ instance_variables.empty?.should == true
642
+ end
643
+ # => extending modules and classes get nothing
644
+ module SubmoduleExtending
645
+ extend CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleExtended
646
+ method_defined?( :configuration_setting ).should == false
647
+ respond_to?( :configuration_setting ).should == false
648
+ instance_variables.empty?.should == true
649
+ end
650
+ # => instances of including and extending classes get nothing
651
+ class ClassIncluding
652
+ include CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleExtended
653
+ method_defined?( :configuration_setting ).should == false
654
+ respond_to?( :configuration_setting ).should == false
655
+ instance_variables.empty?.should == true
656
+ end
657
+ class ClassExtending
658
+ extend CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleExtended
659
+ method_defined?( :configuration_setting ).should == false
660
+ respond_to?( :configuration_setting ).should == false
661
+ instance_variables.empty?.should == true
662
+ end
663
+ end
664
+
665
+ # * module included with setting
666
+ module ::CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleIncluded
667
+ include CascadingConfiguration::Array::Sorted::Unique
668
+ # => singleton gets attr_setting and configurations
669
+ respond_to?( :attr_object_sorted_unique_array ).should == true
670
+ attr_object_sorted_unique_array :configuration_setting
671
+ respond_to?( :configuration_setting ).should == true
672
+ configuration_setting.should == []
673
+ configuration_setting.push( :a_configuration )
674
+ configuration_setting.should == [ :a_configuration ]
675
+ method_defined?( :configuration_setting ).should == false
676
+ instance_variables.empty?.should == true
677
+ # => including modules and classes get attr_setting and configurations
678
+ module SubmoduleIncluding
679
+ include CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleIncluded
680
+ method_defined?( :configuration_setting ).should == false
681
+ respond_to?( :configuration_setting ).should == false
682
+ method_defined?( :configuration_setting ).should == false
683
+ instance_variables.empty?.should == true
684
+ end
685
+ # => extending modules and classes get attr_setting and configurations
686
+ module SubmoduleExtending
687
+ extend CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleIncluded
688
+ # if we're extended then we want to use the eigenclass ancestor chain
689
+ # - the first ancestor will be the extending module
690
+ # - the rest of the ancestors will be the extending module's include chain
691
+ respond_to?( :configuration_setting ).should == false
692
+ method_defined?( :configuration_setting ).should == false
693
+ instance_variables.empty?.should == true
694
+ end
695
+ # => instances of including classes get configurations
696
+ class ClassIncluding
697
+ include CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleIncluded
698
+ method_defined?( :configuration_setting ).should == false
699
+ respond_to?( :configuration_setting ).should == false
700
+ instance_variables.empty?.should == true
701
+ end
702
+ setting_class_including_instance = ClassIncluding.new
703
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
704
+ setting_class_including_instance.instance_variables.empty?.should == true
705
+ # => instances of extending classes get nothing
706
+ class ClassExtending
707
+ extend CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleIncluded
708
+ method_defined?( :configuration_setting ).should == false
709
+ respond_to?( :configuration_setting ).should == false
710
+ instance_variables.empty?.should == true
711
+ end
712
+ setting_class_including_instance = ClassExtending.new
713
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
714
+ setting_class_including_instance.instance_variables.empty?.should == true
715
+ end
716
+
717
+ class CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockClass
718
+ include CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockModuleIncluded::SubmoduleIncluding
719
+ method_defined?( :configuration_setting ).should == false
720
+ respond_to?( :configuration_setting ).should == false
721
+ instance_variables.empty?.should == true
722
+ end
723
+ object_instance_one = CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockClass.new
724
+ object_instance_one.respond_to?( :configuration_setting ).should == false
725
+ object_instance_one.instance_variables.empty?.should == true
726
+ class CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockClass
727
+ method_defined?( :configuration_setting ).should == false
728
+ respond_to?( :configuration_setting ).should == false
729
+ instance_variables.empty?.should == true
730
+ end
731
+ object_instance_two = CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockClassSub1.new
732
+ object_instance_two.respond_to?( :configuration_setting ).should == false
733
+ object_instance_two.instance_variables.empty?.should == true
734
+ class CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::Unique::ObjectConfigurationMockClassSub1
735
+ method_defined?( :configuration_setting ).should == false
736
+ respond_to?( :configuration_setting ).should == false
737
+ instance_variables.empty?.should == true
738
+ end
739
+
740
+ end
741
+
742
+ end