jackbox 0.9.6.3 → 0.9.6.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -13
- data/CHANGES.txt +38 -4
- data/LICENSE.lic +0 -0
- data/README.md +568 -364
- data/lib/jackbox.rb +1 -1
- data/lib/jackbox/injectors.rb +1 -1
- data/lib/jackbox/injectors/coda.rb +2 -0
- data/lib/jackbox/injectors/prelude.rb +2 -0
- data/lib/jackbox/rake.rb +1 -1
- data/lib/jackbox/tools/prefs.rb +1 -1
- data/lib/jackbox/version.rb +1 -1
- data/spec/lib/jackbox/injector_composition_spec.rb +111 -111
- data/spec/lib/jackbox/injector_directives_spec.rb +25 -27
- data/spec/lib/jackbox/injector_inheritance_spec.rb +610 -1004
- data/spec/lib/jackbox/injector_introspection_spec.rb +265 -219
- data/spec/lib/jackbox/injector_namespacing_spec.rb +17 -17
- data/spec/lib/jackbox/injector_spec.rb +26 -0
- data/spec/lib/jackbox/injector_versioning_spec.rb +37 -37
- data/spec/lib/jackbox/jiti_rules_spec.rb +663 -0
- data/spec/lib/jackbox/patterns_spec.rb +224 -122
- data/spec/lib/jackbox/prefs_spec.rb +4 -4
- data/spec/lib/jackbox/reclassing_spec.rb +154 -406
- data/spec/lib/jackbox/vmc_spec.rb +169 -10
- data/spec/lib/jackbox_spec.rb +241 -131
- metadata +26 -26
- data/spec/lib/jackbox/examples/dx_spec.rb +0 -346
@@ -5,107 +5,107 @@ include Injectors
|
|
5
5
|
|
6
6
|
describe "the introspection api in further detail" do
|
7
7
|
|
8
|
-
describe :
|
8
|
+
describe :traits do
|
9
9
|
|
10
|
-
describe "base
|
10
|
+
describe "base traits call" do
|
11
11
|
|
12
|
-
# . Name.
|
13
|
-
# . Name.
|
14
|
-
# . Name.
|
15
|
-
# . Name.
|
16
|
-
# . same as Name.
|
17
|
-
# . Name.
|
18
|
-
# . Name.
|
19
|
-
# . Name.
|
12
|
+
# . Name.traits == [j,......]
|
13
|
+
# . Name.traits.by_name == [:name, ......]
|
14
|
+
# . Name.traits.sym_list == [:name, ......]
|
15
|
+
# . Name.traits.collect_by_name(:name) == [j,......] (default method)
|
16
|
+
# . same as Name.traits :name
|
17
|
+
# . Name.traits.all_by_sym(:name) == [j,......] (default method)
|
18
|
+
# . Name.traits.find_by_name(:name) == j
|
19
|
+
# . Name.traits.#Enumerable...
|
20
20
|
|
21
21
|
before do
|
22
22
|
class InjectorContainer
|
23
|
-
|
24
|
-
|
23
|
+
trait :function
|
24
|
+
trait :style
|
25
25
|
|
26
26
|
inject function, style
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
the 'base call returns now a list of actual
|
30
|
+
the 'base call returns now a list of actual trait objects' do
|
31
31
|
|
32
|
-
# . Name.
|
32
|
+
# . Name.traits == [j,......]
|
33
33
|
|
34
34
|
# class InjectorContainer
|
35
|
-
#
|
36
|
-
#
|
35
|
+
# trait :function
|
36
|
+
# trait :style
|
37
37
|
#
|
38
38
|
# inject function, style
|
39
39
|
# end
|
40
40
|
|
41
|
-
expect(InjectorContainer.
|
42
|
-
expect(InjectorContainer.
|
41
|
+
expect(InjectorContainer.traits).to all( be_an(Injector))
|
42
|
+
expect(InjectorContainer.traits).to eql([InjectorContainer.function.history.last, InjectorContainer.style.history.last])
|
43
43
|
|
44
44
|
end
|
45
45
|
|
46
|
-
the '
|
46
|
+
the 'traits#by_name alias sym_list call now returns the list of trait symbols' do
|
47
47
|
|
48
|
-
# . Name.
|
48
|
+
# . Name.traits.by_name == [:name, ......]
|
49
49
|
|
50
|
-
expect(InjectorContainer.
|
51
|
-
expect(InjectorContainer.
|
50
|
+
expect(InjectorContainer.traits.by_name).to all( be_an(Symbol))
|
51
|
+
expect(InjectorContainer.traits.by_name).to eql([:function, :style])
|
52
52
|
# alias
|
53
|
-
expect(InjectorContainer.
|
53
|
+
expect(InjectorContainer.traits.sym_list).to all( be_an(Symbol))
|
54
54
|
|
55
55
|
end
|
56
56
|
|
57
|
-
the '
|
57
|
+
the 'traits.collect_by_name returns a list of trait objects matching the name' do
|
58
58
|
|
59
|
-
# . Name.
|
59
|
+
# . Name.traits.collect_by_name(:name) == [j,......] (default method)
|
60
60
|
|
61
61
|
ic = InjectorContainer.new
|
62
62
|
ic.enrich InjectorContainer.style
|
63
|
-
ic.
|
63
|
+
ic.traits.by_name.should == [:style, :function, :style]
|
64
64
|
|
65
65
|
# returns [Injector.name == :style, Injector.name == :style] only !!
|
66
|
-
ic.
|
66
|
+
ic.traits.collect_by_name(:style).should all(be_an(Injector).and have_attributes(:name => :style))
|
67
67
|
|
68
68
|
# also aliased
|
69
|
-
ic.
|
69
|
+
ic.traits.all_by_sym(:style).should all(be_an(Injector).and have_attributes(:name => :style))
|
70
70
|
end
|
71
71
|
|
72
|
-
the '
|
72
|
+
the 'traits.find_by_name call returns one item of class Injector by name <sym>' do
|
73
73
|
|
74
|
-
# . Name.
|
74
|
+
# . Name.traits.find_by_name(:name) == j
|
75
75
|
|
76
76
|
ic = InjectorContainer.new
|
77
77
|
ic.enrich InjectorContainer.style
|
78
78
|
|
79
79
|
# result
|
80
|
-
ic.
|
81
|
-
ic.
|
80
|
+
ic.traits.by_name.should == [:style, :function, :style]
|
81
|
+
ic.traits.find_by_name(:style).should be_an(Injector).and( have_attributes(:name => :style)) # the last one !!!
|
82
82
|
|
83
83
|
# also aliased
|
84
|
-
ic.
|
84
|
+
ic.traits.last_by_sym(:style).should be_an(Injector).and( have_attributes(:name => :style)) # the last one !!!
|
85
85
|
|
86
86
|
end
|
87
87
|
|
88
|
-
the 'default calls
|
88
|
+
the 'default calls traits :name/traits :name, :othername, ... get resolved to the previous methods' do
|
89
89
|
|
90
|
-
# . Name.
|
90
|
+
# . Name.traits.#Enumerable...
|
91
91
|
|
92
92
|
ic = InjectorContainer.new
|
93
93
|
ic.enrich InjectorContainer.style
|
94
94
|
|
95
95
|
# result
|
96
|
-
ic.
|
97
|
-
ic.
|
96
|
+
ic.traits(:style).should eql(InjectorContainer.style.history.last)
|
97
|
+
ic.traits(:style, :style).should all(be_an(Injector).and have_attributes(:name => :style))
|
98
98
|
|
99
99
|
end
|
100
100
|
|
101
101
|
end
|
102
102
|
|
103
103
|
|
104
|
-
describe "#
|
104
|
+
describe "#traits(:all) call" do
|
105
105
|
|
106
106
|
before do
|
107
|
-
|
108
|
-
|
107
|
+
trait :Example1
|
108
|
+
trait :Example2
|
109
109
|
Object.inject Example1()
|
110
110
|
end
|
111
111
|
|
@@ -114,73 +114,73 @@ describe "the introspection api in further detail" do
|
|
114
114
|
Example2(:implode)
|
115
115
|
end
|
116
116
|
|
117
|
-
it 'returns all the
|
117
|
+
it 'returns all the traits in the ancestor chain of an object' do
|
118
118
|
|
119
|
-
# Object.eject *Object.
|
119
|
+
# Object.eject *Object.traits rescue [] # clear all traits from other tests
|
120
120
|
|
121
121
|
Hash.inject Example2()
|
122
122
|
|
123
|
-
Hash.new.
|
124
|
-
Hash.new.
|
123
|
+
Hash.new.traits(:all).should all(be_an(Injector))
|
124
|
+
Hash.new.traits(:all).should eql [Example2(), Example1()] # from Object, and Hash
|
125
125
|
|
126
|
-
# as opposed to simple #
|
126
|
+
# as opposed to simple #traits call
|
127
127
|
|
128
|
-
Hash.new.
|
128
|
+
Hash.new.traits.should eql [Example2()] # with no :all option
|
129
129
|
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'with any class' do
|
133
133
|
|
134
|
-
# Object.eject *Object.
|
134
|
+
# Object.eject *Object.traits # clear all traits from other tests
|
135
135
|
|
136
136
|
class AnyClass
|
137
137
|
inject Example2()
|
138
138
|
end
|
139
139
|
|
140
|
-
AnyClass.
|
141
|
-
AnyClass.
|
140
|
+
AnyClass.traits(:all).should all(be_an(Injector))
|
141
|
+
AnyClass.traits(:all).should eql [Example2(), Example1()]
|
142
142
|
|
143
|
-
# as opposed to simple #
|
143
|
+
# as opposed to simple #traits call
|
144
144
|
|
145
|
-
AnyClass.new.
|
145
|
+
AnyClass.new.traits.should eql [Example2()]
|
146
146
|
|
147
147
|
end
|
148
148
|
|
149
|
-
it 'returns all the
|
149
|
+
it 'returns all the traits in the ancestors chain of a module' do
|
150
150
|
|
151
151
|
module AnyModule
|
152
152
|
|
153
153
|
inject Example2() do
|
154
|
-
include
|
154
|
+
include trait :Example3 # compond trait
|
155
155
|
end
|
156
156
|
|
157
157
|
end
|
158
158
|
|
159
|
-
AnyModule.
|
160
|
-
AnyModule.
|
159
|
+
AnyModule.traits(:all).should all(be_an(Injector))
|
160
|
+
AnyModule.traits(:all).should eql [Example2(), Example3()]
|
161
161
|
|
162
|
-
# as opposed to simple #
|
162
|
+
# as opposed to simple #traits call
|
163
163
|
|
164
|
-
AnyModule.
|
164
|
+
AnyModule.traits.should eql [Example2()]
|
165
165
|
|
166
166
|
end
|
167
167
|
|
168
|
-
it 'returns all the
|
168
|
+
it 'returns all the traits in the ancestors chain of a Injector' do
|
169
169
|
|
170
170
|
Example1 do
|
171
171
|
|
172
|
-
include
|
173
|
-
include
|
172
|
+
include trait :Example2 do
|
173
|
+
include trait :Example3 # triple compound trait
|
174
174
|
end
|
175
175
|
|
176
176
|
end
|
177
177
|
|
178
|
-
Example1().
|
179
|
-
Example1().
|
178
|
+
Example1().traits(:all).should all(be_an(Injector))
|
179
|
+
Example1().traits(:all).should eql [Example2(), Example3()]
|
180
180
|
|
181
|
-
# as opposed to simple #
|
181
|
+
# as opposed to simple #traits call
|
182
182
|
|
183
|
-
Example1().
|
183
|
+
Example1().traits.should eql [Example2()]
|
184
184
|
|
185
185
|
end
|
186
186
|
|
@@ -188,26 +188,26 @@ describe "the introspection api in further detail" do
|
|
188
188
|
|
189
189
|
Example1 do
|
190
190
|
|
191
|
-
include
|
192
|
-
include
|
191
|
+
include trait :Example2 do
|
192
|
+
include trait :Example3 # triple compound trait
|
193
193
|
end
|
194
194
|
|
195
195
|
end
|
196
196
|
|
197
|
-
Example1().
|
198
|
-
Example1().
|
199
|
-
Example1().
|
197
|
+
Example1().traits(:all).by_name.should == [:Example2, :Example3]
|
198
|
+
Example1().traits(:all).collect_by_name(:Example3).should all(be_an(Injector).and have_attributes(:name => :Example3))
|
199
|
+
Example1().traits(:all).find_by_name(:Example2).should == Example2()
|
200
200
|
|
201
201
|
end
|
202
202
|
end
|
203
203
|
|
204
204
|
|
205
|
-
describe '#
|
205
|
+
describe '#traits at the class singleton level' do
|
206
206
|
|
207
|
-
the '
|
207
|
+
the 'traits applied at the CLASS instance level, ie: using extend on the class, show up only on the CLASS instance not
|
208
208
|
its object instances and this only after using the :all directive like above' do
|
209
209
|
|
210
|
-
|
210
|
+
trait :class_Instance_trait do
|
211
211
|
def new *args
|
212
212
|
puts "--done--"
|
213
213
|
super(*args)
|
@@ -220,38 +220,38 @@ describe "the introspection api in further detail" do
|
|
220
220
|
|
221
221
|
# extend the class singleton
|
222
222
|
|
223
|
-
InjectorUser.extend
|
223
|
+
InjectorUser.extend class_Instance_trait
|
224
224
|
|
225
225
|
# run tests
|
226
226
|
|
227
|
-
InjectorUser.
|
227
|
+
InjectorUser.traits.size.should == 0 # not using the :all directive
|
228
228
|
|
229
|
-
InjectorUser.
|
230
|
-
InjectorUser.
|
229
|
+
InjectorUser.traits(:all).size.should == 1
|
230
|
+
InjectorUser.traits(:all).should all(be_an(Injector).and have_attributes(:name => :class_Instance_trait))
|
231
231
|
|
232
232
|
# on the class instance
|
233
233
|
|
234
234
|
$stdout.should_receive(:puts).with("--done--")
|
235
235
|
|
236
236
|
iu = InjectorUser.new
|
237
|
-
expect(iu.
|
238
|
-
expect(iu.
|
237
|
+
expect(iu.traits).to be_empty
|
238
|
+
expect(iu.traits(:all)).to be_empty
|
239
239
|
|
240
240
|
end
|
241
241
|
|
242
|
-
the ':all
|
242
|
+
the ':all trait list for classes lists CLASS instance traits first and then OBJECT instance traits' do
|
243
243
|
|
244
|
-
|
245
|
-
|
244
|
+
trait :two
|
245
|
+
trait :one
|
246
246
|
|
247
247
|
Array.inject two # injected on objects of the class
|
248
248
|
Array.extend one # extended on the class instance itself
|
249
249
|
|
250
250
|
# result
|
251
251
|
|
252
|
-
Array.
|
252
|
+
Array.traits(:all).sym_list.should == [:one, :two]
|
253
253
|
|
254
|
-
Array.new.
|
254
|
+
Array.new.traits.sym_list.should == [:two] # :one is member of Array.singleton_class
|
255
255
|
# and does not become part of Array.instances
|
256
256
|
end
|
257
257
|
|
@@ -273,14 +273,14 @@ describe "the introspection api in further detail" do
|
|
273
273
|
|
274
274
|
extend(Histample(), Histample()) # host two items
|
275
275
|
|
276
|
-
|
276
|
+
traits.should == Histample().history # equal at this point
|
277
277
|
|
278
278
|
expect(Histample().history.size).to eq(2)
|
279
|
-
expect(Histample().history.last).to eql(
|
280
|
-
expect(Histample().history.first).to eq(
|
281
|
-
expect(
|
279
|
+
expect(Histample().history.last).to eql(traits.last)
|
280
|
+
expect(Histample().history.first).to eq(traits.first)
|
281
|
+
expect(traits.size).to eq(2)
|
282
282
|
|
283
|
-
eject *
|
283
|
+
eject *traits
|
284
284
|
|
285
285
|
end
|
286
286
|
|
@@ -288,7 +288,7 @@ describe "the introspection api in further detail" do
|
|
288
288
|
|
289
289
|
extend Histample(), Histample()
|
290
290
|
|
291
|
-
|
291
|
+
traits.should == Histample().history
|
292
292
|
|
293
293
|
expect(Histample().history.slice(0)).to be_instance_of(Injector)
|
294
294
|
expect(Histample().history.slice(1)).to be_instance_of(Injector)
|
@@ -301,14 +301,14 @@ describe "the introspection api in further detail" do
|
|
301
301
|
|
302
302
|
extend(Histample(), Histample())
|
303
303
|
|
304
|
-
|
304
|
+
traits.should == Histample().history
|
305
305
|
|
306
306
|
expect(Histample().history.size).to eq(2)
|
307
|
-
expect(
|
307
|
+
expect(traits.size).to eq(2)
|
308
308
|
|
309
|
-
eject *
|
309
|
+
eject *traits
|
310
310
|
|
311
|
-
expect(
|
311
|
+
expect(traits).to be_empty # target traits
|
312
312
|
expect(Histample().history).to be_empty # Injector history
|
313
313
|
|
314
314
|
end
|
@@ -335,20 +335,20 @@ describe "the introspection api in further detail" do
|
|
335
335
|
|
336
336
|
describe :precedent do
|
337
337
|
|
338
|
-
it 'points to the previous
|
338
|
+
it 'points to the previous trait in the history' do
|
339
339
|
|
340
340
|
extend Histample(), Histample()
|
341
341
|
|
342
342
|
# Given that
|
343
|
-
|
343
|
+
traits.should == Histample().history
|
344
344
|
|
345
345
|
# Then
|
346
346
|
expect(Histample().history.last.precedent).to equal(Histample().history.first)
|
347
|
-
expect(Histample().history.last.pre).to equal(
|
348
|
-
expect(
|
349
|
-
expect(
|
347
|
+
expect(Histample().history.last.pre).to equal(traits.first)
|
348
|
+
expect(traits.last.precedent).to equal(Histample().history.first)
|
349
|
+
expect(traits.last.pre).to equal(traits.first)
|
350
350
|
|
351
|
-
eject *
|
351
|
+
eject *traits
|
352
352
|
|
353
353
|
end
|
354
354
|
|
@@ -356,12 +356,12 @@ describe "the introspection api in further detail" do
|
|
356
356
|
|
357
357
|
extend Histample(), Histample()
|
358
358
|
|
359
|
-
|
359
|
+
traits.should == Histample().history
|
360
360
|
|
361
361
|
expect(Histample().history.first.precedent).to equal(Histample().spec)
|
362
|
-
expect(
|
362
|
+
expect(traits.first.precedent).to equal(Histample().spec)
|
363
363
|
|
364
|
-
eject *
|
364
|
+
eject *traits
|
365
365
|
|
366
366
|
end
|
367
367
|
|
@@ -371,13 +371,13 @@ describe "the introspection api in further detail" do
|
|
371
371
|
|
372
372
|
extend Histample(), Histample()
|
373
373
|
|
374
|
-
|
374
|
+
traits.should == Histample().history
|
375
375
|
|
376
376
|
expect(Histample().history.first.precedent).to equal(Histample().spec)
|
377
377
|
expect(Histample().precedent.pre.pre).to equal(Histample().spec)
|
378
378
|
expect(Histample().spec.pre).to eq(Histample().history.last)
|
379
379
|
|
380
|
-
eject *
|
380
|
+
eject *traits
|
381
381
|
|
382
382
|
end
|
383
383
|
|
@@ -387,18 +387,18 @@ describe "the introspection api in further detail" do
|
|
387
387
|
describe :progenitor do
|
388
388
|
|
389
389
|
before do
|
390
|
-
|
390
|
+
trait :Progample
|
391
391
|
end
|
392
392
|
after do
|
393
393
|
Progample(:implode)
|
394
394
|
end
|
395
395
|
|
396
|
-
it 'points to its progenitor: the version of
|
396
|
+
it 'points to its progenitor: the version of trait generating it' do
|
397
397
|
|
398
398
|
expect(Progample().history).to be_empty
|
399
399
|
expect(Progample().progenitor).to equal(Progample().spec)
|
400
400
|
|
401
|
-
# apply the
|
401
|
+
# apply the trait
|
402
402
|
|
403
403
|
extend Progample(), Progample()
|
404
404
|
|
@@ -430,7 +430,7 @@ describe "the introspection api in further detail" do
|
|
430
430
|
extend ProgenitorsTag
|
431
431
|
|
432
432
|
expect(Progample().history.size).to eq(4)
|
433
|
-
expect(Progample().history.last).to equal(
|
433
|
+
expect(Progample().history.last).to equal(traits.first)
|
434
434
|
|
435
435
|
expect(Progample().history.last.progenitor).to equal(ProgenitorsTag)
|
436
436
|
expect(Progample().history.first.progenitor).to equal(Progample().spec)
|
@@ -471,7 +471,7 @@ describe "the introspection api in further detail" do
|
|
471
471
|
|
472
472
|
end
|
473
473
|
|
474
|
-
it 'carries on the metaphor with
|
474
|
+
it 'carries on the metaphor with traits are shared from other objects' do
|
475
475
|
|
476
476
|
suppress_warnings do
|
477
477
|
ProgenitorsTag = Progample()
|
@@ -482,11 +482,11 @@ describe "the introspection api in further detail" do
|
|
482
482
|
end
|
483
483
|
|
484
484
|
class ProgenitorTester2
|
485
|
-
include *ProgenitorTester1.
|
485
|
+
include *ProgenitorTester1.traits # copying traits from second class
|
486
486
|
end
|
487
487
|
|
488
|
-
expect(ProgenitorTester2.
|
489
|
-
expect(ProgenitorTester1.
|
488
|
+
expect(ProgenitorTester2.traits.first.progenitor).to equal(ProgenitorTester1.traits.first)
|
489
|
+
expect(ProgenitorTester1.traits.first.progenitor).to equal(ProgenitorsTag)
|
490
490
|
expect(ProgenitorsTag.progenitor).to equal(Progample().spec)
|
491
491
|
|
492
492
|
end
|
@@ -496,13 +496,13 @@ describe "the introspection api in further detail" do
|
|
496
496
|
describe :lineage do
|
497
497
|
|
498
498
|
before do
|
499
|
-
|
499
|
+
trait :Lineample
|
500
500
|
end
|
501
501
|
after do
|
502
502
|
Lineample(:implode)
|
503
503
|
end
|
504
504
|
|
505
|
-
it 'collects all the progenitors of a line of
|
505
|
+
it 'collects all the progenitors of a line of traits' do
|
506
506
|
|
507
507
|
LineagesTag = Lineample()
|
508
508
|
|
@@ -511,15 +511,15 @@ describe "the introspection api in further detail" do
|
|
511
511
|
end
|
512
512
|
|
513
513
|
class LineageTester2
|
514
|
-
include *LineageTester1.
|
514
|
+
include *LineageTester1.traits
|
515
515
|
end
|
516
516
|
|
517
|
-
expect(LineageTester2.
|
518
|
-
expect(LineageTester1.
|
517
|
+
expect(LineageTester2.traits.first.progenitor).to equal(LineageTester1.traits.first)
|
518
|
+
expect(LineageTester1.traits.first.progenitor).to equal(LineagesTag)
|
519
519
|
expect(LineagesTag.progenitor).to equal(Lineample().spec)
|
520
520
|
|
521
521
|
expect(Lineample().lineage).to eq([Lineample().spec, Lineample()])
|
522
|
-
expect(LineageTester2.
|
522
|
+
expect(LineageTester2.traits.first.lineage).to eq([Lineample().spec, LineagesTag, LineageTester1.traits.first, LineageTester2.traits.first])
|
523
523
|
expect(Lineample().spec.lineage).to eq([Lineample().spec])
|
524
524
|
expect(Lineample().spec.progenitor).to eq(nil)
|
525
525
|
|
@@ -530,8 +530,8 @@ describe "the introspection api in further detail" do
|
|
530
530
|
describe 'equality of Injectors' do
|
531
531
|
|
532
532
|
before do
|
533
|
-
|
534
|
-
|
533
|
+
trait :E
|
534
|
+
trait :F
|
535
535
|
end
|
536
536
|
|
537
537
|
after do
|
@@ -542,59 +542,71 @@ describe "the introspection api in further detail" do
|
|
542
542
|
# For now this is how equality is defined
|
543
543
|
describe 'equality and inequality' do
|
544
544
|
|
545
|
-
it 'allows comparison between
|
545
|
+
it 'allows comparison between traits' do
|
546
546
|
|
547
547
|
# equality
|
548
548
|
##################################
|
549
|
+
|
549
550
|
E().should == E()
|
550
551
|
E().should == E().spec
|
552
|
+
E().should == E().pre
|
551
553
|
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
extend E()
|
557
|
-
injectors.first.should == E()
|
554
|
+
# if
|
555
|
+
ETag1 = E() # with no definitions
|
556
|
+
# then
|
557
|
+
E().should == ETag1 # same thing
|
558
558
|
|
559
|
+
# if
|
560
|
+
extend E() # with no definitions
|
561
|
+
# then
|
562
|
+
traits.first.should == E() # same
|
563
|
+
|
564
|
+
# but
|
565
|
+
E().should == E() # always
|
566
|
+
E().should == E().spec
|
567
|
+
E(:tag).should == E()
|
559
568
|
|
560
|
-
# ** definition **
|
561
|
-
E() do
|
562
|
-
def foo
|
563
|
-
end
|
564
|
-
end
|
565
|
-
# ** definition **
|
566
|
-
|
567
|
-
|
568
569
|
# inequality
|
569
570
|
##################################
|
570
|
-
|
571
|
-
ETag1.should_not == E()
|
572
|
-
injectors.first.should_not == E()
|
573
|
-
|
574
|
-
E(:tag).should == E()
|
571
|
+
|
575
572
|
E().should_not == F()
|
576
|
-
|
573
|
+
|
574
|
+
# if E () definitions **
|
575
|
+
E() do
|
576
|
+
def foo
|
577
|
+
end
|
578
|
+
end
|
579
|
+
|
580
|
+
# then (from above)
|
581
|
+
ETag1.should_not == E()
|
582
|
+
|
583
|
+
# furthermore
|
584
|
+
traits.first.should_not == E()
|
585
|
+
|
586
|
+
# and
|
587
|
+
E().should_not == E().pre
|
588
|
+
|
589
|
+
# but
|
590
|
+
E().should == E() # always
|
591
|
+
E().should == E().spec
|
592
|
+
|
577
593
|
end
|
578
594
|
|
579
595
|
end
|
580
596
|
|
581
597
|
describe :diff do
|
582
|
-
|
583
|
-
it '
|
584
|
-
|
585
|
-
E().diff.class.should be(Array)
|
598
|
+
|
599
|
+
it 'corroborates equality' do
|
586
600
|
|
587
601
|
# equality in the converse expression
|
588
602
|
##################################
|
589
|
-
# debugger
|
590
603
|
E().diff(E()).should be_empty
|
591
604
|
|
592
605
|
# because
|
593
606
|
E().should == E() # like above
|
594
607
|
|
595
608
|
|
596
|
-
# unless changed
|
597
|
-
##################################
|
609
|
+
# unless changed
|
598
610
|
E().diff.should be_empty
|
599
611
|
|
600
612
|
# because
|
@@ -602,18 +614,13 @@ describe "the introspection api in further detail" do
|
|
602
614
|
E().pre.should equal( E().spec )
|
603
615
|
# and
|
604
616
|
E().should == E().spec # like above
|
605
|
-
|
606
|
-
|
607
|
-
# unless there is a delta it cannot be loaded?
|
608
|
-
##################################
|
617
|
+
# also
|
609
618
|
E().diff.should_not be_loaded
|
610
|
-
|
611
619
|
# because
|
612
620
|
E().diff.delta.should be_empty
|
613
621
|
|
614
622
|
|
615
623
|
# tags are the same
|
616
|
-
##################################
|
617
624
|
ETag2 = E()
|
618
625
|
|
619
626
|
E().diff(ETag2).should be_empty
|
@@ -627,107 +634,146 @@ describe "the introspection api in further detail" do
|
|
627
634
|
|
628
635
|
it 'differs once a definition is present' do
|
629
636
|
|
630
|
-
|
631
|
-
|
632
|
-
ETag3 = E()
|
637
|
+
# difference
|
638
|
+
##################################
|
633
639
|
|
640
|
+
#diff(ver=nil) --( The argument ver=nil defaults to the previous version )
|
634
641
|
|
635
|
-
|
636
|
-
E do
|
637
|
-
def foo
|
638
|
-
end
|
639
|
-
end
|
640
|
-
# ** definition **
|
642
|
+
E().diff.class.should be(Array)
|
641
643
|
|
642
644
|
|
643
|
-
|
644
|
-
####################################
|
645
|
-
E().diff(ETag3).should_not be_empty
|
645
|
+
#diff.empty? --( Is the delta empty? The join could still exist (see below). )
|
646
646
|
|
647
|
-
|
648
|
-
ETag3.should_not == E()
|
649
|
-
# and
|
650
|
-
E().diff(ETag3).delta.should == [:foo]
|
651
|
-
|
652
|
-
|
653
|
-
# Still not loaded
|
654
|
-
##################################
|
655
|
-
E().diff(ETag3).should_not be_loaded
|
647
|
+
E().diff.should be_empty
|
656
648
|
|
657
|
-
# because
|
658
|
-
E().diff(ETag3).join.should == []
|
659
|
-
# even though
|
660
|
-
E().diff(ETag3).delta.should == [:foo]
|
661
|
-
|
662
649
|
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
# and
|
667
|
-
E().diff.delta.should == []
|
650
|
+
# because
|
651
|
+
E().diff.delta.should be_empty
|
652
|
+
E().diff.join.should be_empty
|
668
653
|
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
654
|
+
|
655
|
+
# a tag to compare
|
656
|
+
ETag3 = E()
|
657
|
+
|
658
|
+
|
659
|
+
# if some E() definitions **
|
660
|
+
E do
|
661
|
+
def foo
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
|
666
|
+
# E is changed so...
|
667
|
+
E().diff(ETag3).should_not be_empty
|
668
|
+
|
669
|
+
|
670
|
+
# because (like above)
|
671
|
+
ETag3.should_not == E()
|
672
|
+
|
673
|
+
# and
|
674
|
+
|
675
|
+
|
676
|
+
#diff.delta --( The difference in methods )
|
677
|
+
|
678
|
+
E().diff(ETag3).delta.should == [:foo]
|
679
|
+
|
680
|
+
|
681
|
+
#diff.loaded? --( Is there both a join and a delta? )
|
682
|
+
|
683
|
+
E().diff(ETag3).should_not be_loaded
|
684
|
+
|
685
|
+
# because
|
686
|
+
|
687
|
+
|
688
|
+
#diff.join --( The methods common to both )
|
689
|
+
|
690
|
+
E().diff(ETag3).join.should == []
|
691
|
+
|
692
|
+
|
693
|
+
# even though
|
694
|
+
E().diff(ETag3).delta.should == [:foo]
|
695
|
+
|
696
|
+
|
697
|
+
# furthermore
|
698
|
+
E().diff.should == [[], [:foo]]
|
699
|
+
|
700
|
+
|
701
|
+
# being that
|
702
|
+
E().diff.should eq( E().diff(E().precedent) )
|
703
|
+
# and
|
704
|
+
E().progenitor.should equal(E().spec)
|
677
705
|
|
678
706
|
end
|
679
707
|
|
680
|
-
it '
|
708
|
+
it 'continues to work with expansion' do
|
681
709
|
|
682
|
-
# a tag
|
683
|
-
##################################
|
710
|
+
# a tag as precedent
|
684
711
|
ETag4 = E()
|
685
712
|
|
686
713
|
|
687
|
-
#
|
714
|
+
# if more E() definitions **
|
688
715
|
E do
|
689
716
|
def foo
|
690
717
|
end
|
691
718
|
def bar
|
692
719
|
end
|
693
720
|
end
|
694
|
-
# ** definition **
|
695
721
|
|
696
722
|
|
697
|
-
#
|
698
|
-
##################################
|
723
|
+
# then
|
699
724
|
E().diff(ETag4).join.should == []
|
700
725
|
E().diff(ETag4).delta.should == [:foo, :bar]
|
701
|
-
E().diff.join.should == [
|
702
|
-
E().diff.delta.should == []
|
726
|
+
E().diff.join.should == []
|
727
|
+
E().diff.delta.should == [:foo, :bar]
|
703
728
|
|
704
729
|
# being that
|
705
|
-
E().diff.should eq( E().diff( E().
|
730
|
+
E().diff.should eq( E().diff( E().precedent) )
|
706
731
|
E().progenitor.should equal( E().spec )
|
707
732
|
|
708
733
|
end
|
709
734
|
|
710
|
-
it 'creates
|
735
|
+
it 'creates traits for inclusion' do
|
711
736
|
|
712
|
-
|
713
|
-
|
714
|
-
ETag5 = E()
|
737
|
+
# a tag as precedent
|
738
|
+
ETag5 = E()
|
715
739
|
|
716
740
|
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
741
|
+
# if E() definitions **
|
742
|
+
E do
|
743
|
+
def foo
|
744
|
+
:foo
|
745
|
+
end
|
746
|
+
def bar
|
747
|
+
:bar
|
748
|
+
end
|
749
|
+
end
|
725
750
|
|
726
751
|
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
752
|
+
# then
|
753
|
+
E().diff.should_not be_empty
|
754
|
+
|
755
|
+
# being that
|
756
|
+
E().diff.join.should be_empty
|
757
|
+
E().diff.delta.should_not be_empty
|
758
|
+
# as for
|
759
|
+
E().diff.delta.injector.instance_methods.should == [:foo, :bar]
|
760
|
+
# and
|
761
|
+
E().diff.delta.injector.should_not eq(E().diff.join.injector)
|
762
|
+
|
763
|
+
# being that
|
764
|
+
E().diff.join.injector.instance_methods.should be_empty
|
765
|
+
E().diff.delta.injector.instance_methods.should_not be_empty
|
766
|
+
|
767
|
+
# allows the following
|
768
|
+
class Incomplete
|
769
|
+
inject E().diff.delta.injector
|
770
|
+
end
|
771
|
+
# and
|
772
|
+
Incomplete.new.foo.should eq(:foo)
|
773
|
+
|
774
|
+
# being that
|
775
|
+
E().diff.delta.injector.should be_instance_of(Injector)
|
776
|
+
E().diff.delta.injector.should be_instance_of(Trait)
|
731
777
|
|
732
778
|
end
|
733
779
|
|