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,741 @@
1
+
2
+ require_relative '../../../lib/cascading_configuration.rb'
3
+
4
+ describe CascadingConfiguration::Array::Sorted do
5
+
6
+ #######################
7
+ # attr_sorted_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::ConfigurationMockModuleExtended
25
+ extend CascadingConfiguration::Array::Sorted
26
+ # => singleton gets attr_setting and configurations
27
+ respond_to?( :attr_sorted_array ).should == true
28
+ respond_to?( :attr_configuration_sorted_array ).should == true
29
+ attr_sorted_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::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::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::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::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::ConfigurationMockModuleIncluded
67
+ include CascadingConfiguration::Array::Sorted
68
+ # => singleton gets attr_setting and configurations
69
+ respond_to?( :attr_sorted_array ).should == true
70
+ attr_sorted_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::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::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::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::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::ConfigurationMockClass
132
+ include CascadingConfiguration::Array::Sorted::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::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::ConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::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::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::ConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::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::ConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
163
+ CascadingConfiguration::Array::Sorted::ConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
164
+ CascadingConfiguration::Array::Sorted::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::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::ConfigurationMockClassSub1.configuration_setting.freeze!
173
+ CascadingConfiguration::Array::Sorted::ConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
174
+ CascadingConfiguration::Array::Sorted::ConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
175
+ CascadingConfiguration::Array::Sorted::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::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_array #
184
+ # attr_class_sorted_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::ClassConfigurationMockModuleExtended
202
+ extend CascadingConfiguration::Array::Sorted
203
+ # => singleton gets attr_setting and configurations
204
+ respond_to?( :attr_module_sorted_array ).should == true
205
+ respond_to?( :attr_module_configuration_sorted_array ).should == true
206
+ method( :attr_module_sorted_array ).should == method( :attr_class_sorted_array )
207
+ attr_module_sorted_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::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::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::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::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::ClassConfigurationMockModuleIncluded
245
+ include CascadingConfiguration::Array::Sorted
246
+ # => singleton gets attr_setting and configurations
247
+ respond_to?( :attr_module_sorted_array ).should == true
248
+ attr_module_sorted_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::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::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::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::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::ClassConfigurationMockClass
302
+ include CascadingConfiguration::Array::Sorted::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::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::ClassConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::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::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::ClassConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::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::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :another_configuration, :some_other_configuration ]
332
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClass.configuration_setting.push( :a_yet_unused_configuration )
333
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
334
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
335
+
336
+ # freeze ancestor setting
337
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClassSub1.configuration_setting.freeze!
338
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
339
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClass.configuration_setting.push( :non_cascading_configuration )
340
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClass.configuration_setting.should == [ :a_configuration, :a_yet_unused_configuration, :another_configuration, :non_cascading_configuration, :some_other_configuration ]
341
+ CascadingConfiguration::Array::Sorted::ClassConfigurationMockClassSub1.configuration_setting.should == [ :a_yet_unused_configuration, :another_configuration, :some_other_configuration ]
342
+
343
+ end
344
+
345
+ #############################
346
+ # attr_local_sorted_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::LocalConfigurationMockModuleExtended
364
+ extend CascadingConfiguration::Array::Sorted
365
+ # => singleton gets attr_setting and configurations
366
+ respond_to?( :attr_local_sorted_array ).should == true
367
+ respond_to?( :attr_local_configuration_sorted_array ).should == true
368
+ attr_local_sorted_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::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::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::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::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::LocalConfigurationMockModuleIncluded
406
+ include CascadingConfiguration::Array::Sorted
407
+ # => singleton gets attr_setting and configurations
408
+ respond_to?( :attr_local_sorted_array ).should == true
409
+ attr_local_sorted_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::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::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::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::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::LocalConfigurationMockClass
456
+ include CascadingConfiguration::Array::Sorted::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::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::LocalConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::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::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::LocalConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::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_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::InstanceConfigurationMockModuleExtended
499
+ extend CascadingConfiguration::Array::Sorted
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::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::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::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::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::InstanceConfigurationMockModuleIncluded
533
+ include CascadingConfiguration::Array::Sorted
534
+ # => singleton gets attr_setting and configurations
535
+ respond_to?( :attr_instance_sorted_array ).should == true
536
+ attr_instance_sorted_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::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::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::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::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::InstanceConfigurationMockClass
581
+ include CascadingConfiguration::Array::Sorted::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::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::InstanceConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::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::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::InstanceConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::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
+ # attr_object_sorted_array #
607
+ ##############################
608
+
609
+ it 'can define an object configuration array, which will not cascade' do
610
+
611
+ # possibilities:
612
+ # * module extended with setting
613
+ # => singleton gets attr_setting and configurations
614
+ # => including modules and classes get nothing
615
+ # => extending modules and classes get nothing
616
+ # => instances of including and extending classes get nothing
617
+ # * module included with setting
618
+ # => singleton gets attr_setting and configurations
619
+ # => including modules and classes get attr_setting and configurations
620
+ # => instances of including classes get configurations
621
+ # => extending modules and classes get attr_setting and configurations
622
+ # => instances of extending classes get nothing
623
+ module ::CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleExtended
624
+ extend CascadingConfiguration::Array::Sorted
625
+ # => singleton gets attr_setting and configurations
626
+ respond_to?( :attr_object_configuration_sorted_array ).should == true
627
+ respond_to?( :attr_object_sorted_array ).should == true
628
+ attr_object_sorted_array :configuration_setting
629
+ respond_to?( :configuration_setting ).should == true
630
+ configuration_setting.should == []
631
+ configuration_setting.push( :a_configuration )
632
+ configuration_setting.should == [ :a_configuration ]
633
+ method_defined?( :configuration_setting ).should == false
634
+ instance_variables.empty?.should == true
635
+ # => including modules and classes get nothing
636
+ module SubmoduleIncluding
637
+ include CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleExtended
638
+ method_defined?( :configuration_setting ).should == false
639
+ respond_to?( :configuration_setting ).should == false
640
+ instance_variables.empty?.should == true
641
+ end
642
+ # => extending modules and classes get nothing
643
+ module SubmoduleExtending
644
+ extend CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleExtended
645
+ method_defined?( :configuration_setting ).should == false
646
+ respond_to?( :configuration_setting ).should == false
647
+ instance_variables.empty?.should == true
648
+ end
649
+ # => instances of including and extending classes get nothing
650
+ class ClassIncluding
651
+ include CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleExtended
652
+ method_defined?( :configuration_setting ).should == false
653
+ respond_to?( :configuration_setting ).should == false
654
+ instance_variables.empty?.should == true
655
+ end
656
+ class ClassExtending
657
+ extend CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleExtended
658
+ method_defined?( :configuration_setting ).should == false
659
+ respond_to?( :configuration_setting ).should == false
660
+ instance_variables.empty?.should == true
661
+ end
662
+ end
663
+
664
+ # * module included with setting
665
+ module ::CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleIncluded
666
+ include CascadingConfiguration::Array::Sorted
667
+ # => singleton gets attr_setting and configurations
668
+ respond_to?( :attr_object_sorted_array ).should == true
669
+ attr_object_sorted_array :configuration_setting
670
+ respond_to?( :configuration_setting ).should == true
671
+ configuration_setting.should == []
672
+ configuration_setting.push( :a_configuration )
673
+ configuration_setting.should == [ :a_configuration ]
674
+ method_defined?( :configuration_setting ).should == false
675
+ instance_variables.empty?.should == true
676
+ # => including modules and classes get attr_setting and configurations
677
+ module SubmoduleIncluding
678
+ include CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleIncluded
679
+ method_defined?( :configuration_setting ).should == false
680
+ respond_to?( :configuration_setting ).should == false
681
+ method_defined?( :configuration_setting ).should == false
682
+ instance_variables.empty?.should == true
683
+ end
684
+ # => extending modules and classes get attr_setting and configurations
685
+ module SubmoduleExtending
686
+ extend CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleIncluded
687
+ # if we're extended then we want to use the eigenclass ancestor chain
688
+ # - the first ancestor will be the extending module
689
+ # - the rest of the ancestors will be the extending module's include chain
690
+ respond_to?( :configuration_setting ).should == false
691
+ method_defined?( :configuration_setting ).should == false
692
+ instance_variables.empty?.should == true
693
+ end
694
+ # => instances of including classes get configurations
695
+ class ClassIncluding
696
+ include CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleIncluded
697
+ method_defined?( :configuration_setting ).should == false
698
+ respond_to?( :configuration_setting ).should == false
699
+ instance_variables.empty?.should == true
700
+ end
701
+ setting_class_including_instance = ClassIncluding.new
702
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
703
+ setting_class_including_instance.instance_variables.empty?.should == true
704
+ # => instances of extending classes get nothing
705
+ class ClassExtending
706
+ extend CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleIncluded
707
+ method_defined?( :configuration_setting ).should == false
708
+ respond_to?( :configuration_setting ).should == false
709
+ instance_variables.empty?.should == true
710
+ end
711
+ setting_class_including_instance = ClassExtending.new
712
+ setting_class_including_instance.respond_to?( :configuration_setting ).should == false
713
+ setting_class_including_instance.instance_variables.empty?.should == true
714
+ end
715
+
716
+ class CascadingConfiguration::Array::Sorted::ObjectConfigurationMockClass
717
+ include CascadingConfiguration::Array::Sorted::ObjectConfigurationMockModuleIncluded::SubmoduleIncluding
718
+ method_defined?( :configuration_setting ).should == false
719
+ respond_to?( :configuration_setting ).should == false
720
+ instance_variables.empty?.should == true
721
+ end
722
+ object_instance_one = CascadingConfiguration::Array::Sorted::ObjectConfigurationMockClass.new
723
+ object_instance_one.respond_to?( :configuration_setting ).should == false
724
+ object_instance_one.instance_variables.empty?.should == true
725
+ class CascadingConfiguration::Array::Sorted::ObjectConfigurationMockClassSub1 < CascadingConfiguration::Array::Sorted::ObjectConfigurationMockClass
726
+ method_defined?( :configuration_setting ).should == false
727
+ respond_to?( :configuration_setting ).should == false
728
+ instance_variables.empty?.should == true
729
+ end
730
+ object_instance_two = CascadingConfiguration::Array::Sorted::ObjectConfigurationMockClassSub1.new
731
+ object_instance_two.respond_to?( :configuration_setting ).should == false
732
+ object_instance_two.instance_variables.empty?.should == true
733
+ class CascadingConfiguration::Array::Sorted::ObjectConfigurationMockClassSub2 < CascadingConfiguration::Array::Sorted::ObjectConfigurationMockClassSub1
734
+ method_defined?( :configuration_setting ).should == false
735
+ respond_to?( :configuration_setting ).should == false
736
+ instance_variables.empty?.should == true
737
+ end
738
+
739
+ end
740
+
741
+ end