dbd 0.0.11 → 0.0.12
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 +4 -4
- data/Guardfile +0 -1
- data/HISTORY.txt +9 -0
- data/README.md +47 -39
- data/bin/test_1.rb +4 -4
- data/bin/test_5.rb +4 -4
- data/docs/test.rb +11 -11
- data/lib/dbd.rb +2 -2
- data/lib/dbd/context.rb +65 -0
- data/lib/dbd/context_fact.rb +76 -0
- data/lib/dbd/errors.rb +1 -1
- data/lib/dbd/fact.rb +37 -37
- data/lib/dbd/fact/collection.rb +5 -5
- data/lib/dbd/fact/factory.rb +6 -6
- data/lib/dbd/graph.rb +2 -2
- data/lib/dbd/resource.rb +25 -24
- data/lib/dbd/version.rb +1 -1
- data/spec/lib/dbd/context/context_spec.rb +74 -0
- data/spec/lib/dbd/context_fact/methods_spec.rb +79 -0
- data/spec/lib/dbd/context_fact/new_spec.rb +51 -0
- data/spec/lib/dbd/context_fact/test_factories_spec.rb +24 -0
- data/spec/lib/dbd/errors/errors_spec.rb +30 -0
- data/spec/lib/dbd/fact/collection/collection_spec.rb +58 -58
- data/spec/lib/dbd/fact/factory/factory_spec.rb +3 -3
- data/spec/lib/dbd/fact/methods_spec.rb +12 -12
- data/spec/lib/dbd/fact/new_spec.rb +9 -9
- data/spec/lib/dbd/fact/subject/test_factories_spec.rb +4 -4
- data/spec/lib/dbd/fact/test_factories_spec.rb +18 -18
- data/spec/lib/dbd/graph/add_to_graph_spec.rb +22 -22
- data/spec/lib/dbd/graph/from_csv_spec.rb +16 -16
- data/spec/lib/dbd/graph/test_factories_spec.rb +11 -11
- data/spec/lib/dbd/graph/to_csv_spec.rb +18 -18
- data/spec/lib/dbd/performance_spec.rb +4 -4
- data/spec/lib/dbd/resource/collection_spec.rb +28 -30
- data/spec/lib/dbd/resource/new_spec.rb +10 -11
- data/spec/lib/dbd/resource/test_factories_spec.rb +8 -7
- data/spec/lib/dbd/version/version_spec.rb +9 -0
- data/spec/test_factories/context.rb +16 -0
- data/spec/test_factories/{provenance_fact.rb → context_fact.rb} +6 -6
- data/spec/test_factories/fact.rb +23 -23
- data/spec/test_factories/fact/subject.rb +1 -1
- data/spec/test_factories/graph.rb +7 -7
- data/spec/test_factories/resource.rb +15 -10
- metadata +20 -16
- data/lib/dbd/provenance_fact.rb +0 -77
- data/lib/dbd/provenance_resource.rb +0 -63
- data/spec/lib/dbd/provenance_fact/methods_spec.rb +0 -78
- data/spec/lib/dbd/provenance_fact/new_spec.rb +0 -51
- data/spec/lib/dbd/provenance_fact/test_factories_spec.rb +0 -24
- data/spec/lib/dbd/provenance_resource/provenance_resource_spec.rb +0 -75
- data/spec/test_factories/provenance_resource.rb +0 -16
@@ -4,19 +4,19 @@ module Dbd
|
|
4
4
|
class Fact
|
5
5
|
describe Collection do
|
6
6
|
|
7
|
-
let(:
|
8
|
-
let(:
|
7
|
+
let(:context_subject_1) { Fact.factory.new_subject }
|
8
|
+
let(:context_subject_2) { Fact.factory.new_subject }
|
9
9
|
|
10
|
-
let(:
|
11
|
-
let(:
|
12
|
-
let(:
|
10
|
+
let(:context_fact_visibility) { TestFactories::ContextFact.visibility(context_subject_1) }
|
11
|
+
let(:context_fact_created_by) { TestFactories::ContextFact.created_by(context_subject_1) }
|
12
|
+
let(:context_fact_original_source) { TestFactories::ContextFact.original_source(context_subject_2) }
|
13
13
|
|
14
|
-
let(:fact_1) { TestFactories::Fact.fact_1(
|
15
|
-
let(:fact_2_with_subject) { TestFactories::Fact.fact_2_with_subject(
|
16
|
-
let(:fact_3_with_subject) { TestFactories::Fact.fact_3_with_subject(
|
14
|
+
let(:fact_1) { TestFactories::Fact.fact_1(context_subject_1) }
|
15
|
+
let(:fact_2_with_subject) { TestFactories::Fact.fact_2_with_subject(context_subject_1) }
|
16
|
+
let(:fact_3_with_subject) { TestFactories::Fact.fact_3_with_subject(context_subject_1) }
|
17
17
|
|
18
|
-
let(:fact_2_3) { TestFactories::Fact::Collection.fact_2_3(
|
19
|
-
let(:
|
18
|
+
let(:fact_2_3) { TestFactories::Fact::Collection.fact_2_3(context_subject_1) }
|
19
|
+
let(:context_facts) { TestFactories::Fact::Collection.context_facts(context_subject_1) }
|
20
20
|
|
21
21
|
let(:subject) do
|
22
22
|
Object.new.tap do |object_with_Fact_Collection|
|
@@ -43,13 +43,13 @@ module Dbd
|
|
43
43
|
subject.size.should == 1
|
44
44
|
end
|
45
45
|
|
46
|
-
it 'adding a
|
47
|
-
subject <<
|
46
|
+
it 'adding a context_fact works' do
|
47
|
+
subject << context_fact_visibility
|
48
48
|
subject.size.should == 1
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'returns self to allow chaining' do
|
52
|
-
(subject <<
|
52
|
+
(subject << context_fact_visibility).should == subject
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -68,14 +68,14 @@ module Dbd
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
describe 'adding a fact with a ref to a
|
71
|
+
describe 'adding a fact with a ref to a context_fact' do
|
72
72
|
|
73
|
-
it 'fact_2_with_subject has a
|
74
|
-
subject <<
|
75
|
-
subject <<
|
73
|
+
it 'fact_2_with_subject has a context_subject that refers to context_fact_visibility and context_fact_created_by' do
|
74
|
+
subject << context_fact_visibility
|
75
|
+
subject << context_fact_created_by
|
76
76
|
subject << fact_2_with_subject
|
77
|
-
|
78
|
-
subject.by_subject(
|
77
|
+
context_subject = fact_1.context_subject
|
78
|
+
subject.by_subject(context_subject).should == [context_fact_visibility, context_fact_created_by]
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -136,37 +136,37 @@ module Dbd
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
describe '
|
140
|
-
it 'adding a
|
141
|
-
subject <<
|
139
|
+
describe 'context_facts must all come before first use by a fact' do
|
140
|
+
it 'adding a context_fact, depending fact, another context_fact with same subject fail' do
|
141
|
+
subject << context_fact_visibility
|
142
142
|
subject << fact_2_with_subject
|
143
|
-
lambda
|
143
|
+
lambda{ subject << context_fact_created_by }.should raise_error OutOfOrderError
|
144
144
|
end
|
145
145
|
|
146
146
|
# testing private functionality (kept temporarily as documentation)
|
147
|
-
# A hash with all the
|
148
|
-
# Needed for the validation that no
|
147
|
+
# A hash with all the context_subjects that are used by at least one fact.
|
148
|
+
# Needed for the validation that no context_fact may be added that is
|
149
149
|
# referred from a fact that is already in the fact stream.
|
150
|
-
describe '
|
150
|
+
describe 'used_context_subjects' do
|
151
151
|
# testing an internal variable ...
|
152
152
|
|
153
|
-
let(:
|
154
|
-
subject.instance_variable_get(:@
|
153
|
+
let(:used_context_subjects) do
|
154
|
+
subject.instance_variable_get(:@used_context_subjects)
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'is empty initially' do
|
158
|
-
|
158
|
+
used_context_subjects.should be_empty
|
159
159
|
end
|
160
160
|
|
161
|
-
it 'adding a
|
162
|
-
subject <<
|
163
|
-
|
161
|
+
it 'adding a context_fact alone does not create an entry' do
|
162
|
+
subject << context_fact_visibility
|
163
|
+
used_context_subjects.should be_empty
|
164
164
|
end
|
165
165
|
|
166
|
-
it 'adding a
|
167
|
-
subject <<
|
166
|
+
it 'adding a context_fact and a depending fact create an entry' do
|
167
|
+
subject << context_fact_visibility
|
168
168
|
subject << fact_2_with_subject
|
169
|
-
|
169
|
+
used_context_subjects[context_subject_1].should == true
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
@@ -177,8 +177,8 @@ module Dbd
|
|
177
177
|
end
|
178
178
|
|
179
179
|
it 'raises FactError with message when fact.errors has errors' do
|
180
|
-
|
181
|
-
lambda { subject <<
|
180
|
+
context_fact_visibility.stub(:errors).and_return(['Error 1', 'Error 2'])
|
181
|
+
lambda { subject << context_fact_visibility } . should raise_error(
|
182
182
|
FactError,
|
183
183
|
'Error 1, Error 2.')
|
184
184
|
end
|
@@ -186,49 +186,49 @@ module Dbd
|
|
186
186
|
|
187
187
|
describe 'by_subject : ' do
|
188
188
|
it 'finds entries for a given subject' do
|
189
|
-
subject <<
|
190
|
-
subject <<
|
191
|
-
subject <<
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
subject.by_subject(
|
196
|
-
subject.by_subject(
|
197
|
-
subject.by_subject(
|
189
|
+
subject << context_fact_visibility
|
190
|
+
subject << context_fact_created_by
|
191
|
+
subject << context_fact_original_source
|
192
|
+
context_fact_visibility.subject.should == context_subject_1 # assert test set-up
|
193
|
+
context_fact_created_by.subject.should == context_subject_1 # assert test set-up
|
194
|
+
context_fact_original_source.subject.should == context_subject_2 # assert test set-up
|
195
|
+
subject.by_subject(context_subject_1).first.should == context_fact_visibility
|
196
|
+
subject.by_subject(context_subject_1).last.should == context_fact_created_by
|
197
|
+
subject.by_subject(context_subject_2).single.should == context_fact_original_source
|
198
198
|
end
|
199
199
|
end
|
200
200
|
|
201
201
|
describe 'TestFactories::Fact::Collection' do
|
202
202
|
describe '.fact_2_3' do
|
203
|
-
it 'has the given
|
203
|
+
it 'has the given context_subject with explicit subject arg' do
|
204
204
|
fact_2_3.each do |fact|
|
205
|
-
fact.
|
205
|
+
fact.context_subject.should == context_subject_1
|
206
206
|
end
|
207
207
|
end
|
208
208
|
end
|
209
209
|
|
210
|
-
describe '.
|
211
|
-
it 'has a
|
212
|
-
|
213
|
-
|
210
|
+
describe '.context_facts' do
|
211
|
+
it 'has a visibility' do
|
212
|
+
context_facts.select do |context_fact|
|
213
|
+
context_fact.predicate == 'context:visibility'
|
214
214
|
end.size.should == 1
|
215
215
|
end
|
216
216
|
|
217
217
|
it 'has a created_by' do
|
218
|
-
|
219
|
-
|
218
|
+
context_facts.select do |context_fact|
|
219
|
+
context_fact.predicate == 'dcterms:creator'
|
220
220
|
end.size.should == 1
|
221
221
|
end
|
222
222
|
|
223
223
|
it 'has an original_source' do
|
224
|
-
|
225
|
-
|
224
|
+
context_facts.select do |context_fact|
|
225
|
+
context_fact.predicate == 'prov:source'
|
226
226
|
end.size.should == 1
|
227
227
|
end
|
228
228
|
|
229
229
|
it 'has the given subjects with explicit subject arg' do
|
230
|
-
|
231
|
-
|
230
|
+
context_facts.each do |context_fact|
|
231
|
+
context_fact.subject.should == context_subject_1
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
@@ -61,12 +61,12 @@ module Dbd
|
|
61
61
|
with_validation(string_values)
|
62
62
|
end
|
63
63
|
|
64
|
-
it 'for a nil
|
64
|
+
it 'for a nil context_subject (for context_facts)' do
|
65
65
|
string_values[2] = nil
|
66
66
|
with_validation(string_values)
|
67
67
|
end
|
68
68
|
|
69
|
-
it 'for an empty
|
69
|
+
it 'for an empty context_subject (for context_facts)' do
|
70
70
|
string_values[2] = ''
|
71
71
|
with_validation(string_values)
|
72
72
|
end
|
@@ -83,7 +83,7 @@ module Dbd
|
|
83
83
|
lambda{ with_validation(string_values) }.should raise_error(FactError)
|
84
84
|
end
|
85
85
|
|
86
|
-
it 'for invalid
|
86
|
+
it 'for invalid context_subject' do
|
87
87
|
string_values[2] = 'foo'
|
88
88
|
lambda{ with_validation(string_values) }.should raise_error(FactError)
|
89
89
|
end
|
@@ -4,12 +4,12 @@ module Dbd
|
|
4
4
|
describe Fact do
|
5
5
|
|
6
6
|
let(:factory) { described_class.factory }
|
7
|
-
let(:
|
7
|
+
let(:context_subject) { factory.new_subject }
|
8
8
|
let(:subject) { factory.new_subject }
|
9
|
-
let(:fact_1) { TestFactories::Fact.fact_1(
|
10
|
-
let(:fact_2_with_subject) { TestFactories::Fact.fact_2_with_subject(
|
11
|
-
let(:fact_with_newline) { TestFactories::Fact.fact_with_newline(
|
12
|
-
let(:fact_with_special_chars) { TestFactories::Fact.fact_with_special_chars(
|
9
|
+
let(:fact_1) { TestFactories::Fact.fact_1(context_subject) }
|
10
|
+
let(:fact_2_with_subject) { TestFactories::Fact.fact_2_with_subject(context_subject) }
|
11
|
+
let(:fact_with_newline) { TestFactories::Fact.fact_with_newline(context_subject) }
|
12
|
+
let(:fact_with_special_chars) { TestFactories::Fact.fact_with_special_chars(context_subject) }
|
13
13
|
let(:full_fact) { TestFactories::Fact.full_fact }
|
14
14
|
|
15
15
|
describe '.factory' do
|
@@ -47,7 +47,7 @@ module Dbd
|
|
47
47
|
end
|
48
48
|
|
49
49
|
describe 'short' do
|
50
|
-
it 'for a base fact shows
|
50
|
+
it 'for a base fact shows context, subject, predicate, object' do
|
51
51
|
fact_1.subject = subject
|
52
52
|
fact_1.time_stamp = TimeStamp.new
|
53
53
|
fact_1.short.should match(/^[0-9a-f]{8} : [0-9a-f]{8} : http:\/\/example\.org\/test\/ : Gandhi$/)
|
@@ -86,14 +86,14 @@ module Dbd
|
|
86
86
|
fact_2_with_subject.errors.should be_empty
|
87
87
|
end
|
88
88
|
|
89
|
-
describe 'without
|
89
|
+
describe 'without context_subject' do
|
90
90
|
|
91
91
|
before(:each) do
|
92
|
-
fact_2_with_subject.stub(:
|
92
|
+
fact_2_with_subject.stub(:context_subject).and_return(nil)
|
93
93
|
end
|
94
94
|
|
95
95
|
it 'errors returns an array with 1 error message' do
|
96
|
-
fact_2_with_subject.errors.single.should match(/
|
96
|
+
fact_2_with_subject.errors.single.should match(/ContextFact subject is missing/)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -139,9 +139,9 @@ module Dbd
|
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
|
-
describe '
|
143
|
-
it 'is false for a base fact or derived from it that is not a
|
144
|
-
fact_1.
|
142
|
+
describe 'context_fact?' do
|
143
|
+
it 'is false for a base fact or derived from it that is not a ContextFact ' do
|
144
|
+
fact_1.context_fact?.should be_false
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -3,10 +3,10 @@ require 'spec_helper'
|
|
3
3
|
module Dbd
|
4
4
|
describe Fact do
|
5
5
|
let(:factory) { described_class.factory}
|
6
|
-
let(:
|
6
|
+
let(:context_subject) { factory.new_subject }
|
7
7
|
let(:subject) { factory.new_subject }
|
8
|
-
let(:fact_1) { TestFactories::Fact.fact_1(
|
9
|
-
let(:fact_2_with_subject) { TestFactories::Fact.fact_2_with_subject(
|
8
|
+
let(:fact_1) { TestFactories::Fact.fact_1(context_subject) }
|
9
|
+
let(:fact_2_with_subject) { TestFactories::Fact.fact_2_with_subject(context_subject) }
|
10
10
|
let(:data_predicate) { 'http://example.org/test/name' }
|
11
11
|
let(:string_object_1) { 'Gandhi' }
|
12
12
|
let(:id_valid_regexp) { described_class::ID.valid_regexp }
|
@@ -38,8 +38,8 @@ module Dbd
|
|
38
38
|
lambda{ fact_with_incorrect_time_stamp }.should raise_error(ArgumentError)
|
39
39
|
end
|
40
40
|
|
41
|
-
it 'new sets the
|
42
|
-
fact_1.
|
41
|
+
it 'new sets the context_subject' do
|
42
|
+
fact_1.context_subject.should == context_subject
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'new sets the subject' do
|
@@ -75,11 +75,11 @@ module Dbd
|
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
describe '
|
79
|
-
it 'sets the value for
|
78
|
+
describe 'update_used_context_subjects' do
|
79
|
+
it 'sets the value for context_subject to true for a fact' do
|
80
80
|
h = {}
|
81
|
-
fact_1.
|
82
|
-
h[fact_1.
|
81
|
+
fact_1.update_used_context_subjects(h)
|
82
|
+
h[fact_1.context_subject].should == true
|
83
83
|
end
|
84
84
|
end
|
85
85
|
end
|
@@ -5,7 +5,7 @@ module TestFactories
|
|
5
5
|
describe Subject do
|
6
6
|
|
7
7
|
let(:fixed_subject) { described_class.fixed_subject }
|
8
|
-
let(:
|
8
|
+
let(:fixed_context_subject) { described_class.fixed_context_subject }
|
9
9
|
|
10
10
|
describe 'fixed_subject' do
|
11
11
|
it 'fixed_subject is exactly this fixed subject' do
|
@@ -13,9 +13,9 @@ module TestFactories
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe '
|
17
|
-
it '
|
18
|
-
|
16
|
+
describe 'fixed_context_subject' do
|
17
|
+
it 'fixed_context_subject is exactly this fixed subject' do
|
18
|
+
fixed_context_subject.should == '40fab407-9b04-4a51-9a52-d978abfcbb1f'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -2,23 +2,23 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module TestFactories
|
4
4
|
describe Fact do
|
5
|
-
let(:
|
5
|
+
let(:context_subject) { ContextFact.new_subject }
|
6
6
|
let(:subject) { described_class.new_subject }
|
7
7
|
let(:data_predicate) { 'http://example.org/test/name' }
|
8
8
|
let(:string_object_1) { 'Gandhi' }
|
9
|
-
let(:fact_2_with_subject) { described_class.fact_2_with_subject(
|
9
|
+
let(:fact_2_with_subject) { described_class.fact_2_with_subject(context_subject) }
|
10
10
|
let(:full_fact) { described_class.full_fact }
|
11
11
|
|
12
12
|
describe 'factory works' do
|
13
|
-
it 'with explicit
|
14
|
-
fact_2_with_subject.
|
13
|
+
it 'with explicit context_subject' do
|
14
|
+
fact_2_with_subject.context_subject.should be_a(context_subject.class)
|
15
15
|
fact_2_with_subject.subject.should be_a(subject.class)
|
16
16
|
fact_2_with_subject.predicate.should be_a(data_predicate.class)
|
17
17
|
fact_2_with_subject.object.should be_a(string_object_1.class)
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'without explicit
|
21
|
-
described_class.fact_1.
|
20
|
+
it 'without explicit context_subject' do
|
21
|
+
described_class.fact_1.context_subject.should be_nil
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'fact_2_with_subject should not raise_error' do
|
@@ -31,8 +31,8 @@ module TestFactories
|
|
31
31
|
|
32
32
|
describe 'data_fact' do
|
33
33
|
describe 'without arguments' do
|
34
|
-
it 'has empty
|
35
|
-
described_class.data_fact.
|
34
|
+
it 'has empty context_subject' do
|
35
|
+
described_class.data_fact.context_subject.should be_nil
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'has empty subject' do
|
@@ -40,25 +40,25 @@ module TestFactories
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
describe 'with
|
44
|
-
it 'has
|
45
|
-
described_class.data_fact(
|
46
|
-
|
43
|
+
describe 'with context_subject' do
|
44
|
+
it 'has context_subject' do
|
45
|
+
described_class.data_fact(context_subject).
|
46
|
+
context_subject.should == context_subject
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'has empty subject' do
|
50
|
-
described_class.data_fact(
|
50
|
+
described_class.data_fact(context_subject).subject.should be_nil
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
describe 'with
|
55
|
-
it 'has
|
56
|
-
described_class.data_fact(
|
57
|
-
|
54
|
+
describe 'with context_subject and subject' do
|
55
|
+
it 'has context_subject' do
|
56
|
+
described_class.data_fact(context_subject, subject).
|
57
|
+
context_subject.should == context_subject
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'has subject' do
|
61
|
-
described_class.data_fact(
|
61
|
+
described_class.data_fact(context_subject, subject).
|
62
62
|
subject.should == subject
|
63
63
|
end
|
64
64
|
end
|
@@ -9,16 +9,16 @@ module Dbd
|
|
9
9
|
|
10
10
|
let(:data_fact) { TestFactories::Fact.data_fact(new_subject, new_subject) }
|
11
11
|
let(:fact_no_subject) { TestFactories::Fact.data_fact(new_subject, nil) }
|
12
|
-
let(:
|
12
|
+
let(:fact_no_context) { TestFactories::Fact.data_fact(nil, new_subject) }
|
13
13
|
|
14
|
-
let(:
|
15
|
-
let(:
|
14
|
+
let(:context_facts) { TestFactories::Fact::Collection.context_facts(new_subject) }
|
15
|
+
let(:context_fact_1) { context_facts.first }
|
16
16
|
|
17
17
|
let(:subject_regexp) { Fact::Subject.regexp }
|
18
18
|
|
19
|
-
let(:
|
20
|
-
let(:resource) { TestFactories::Resource.facts_resource(
|
21
|
-
let(:resource_array) { [
|
19
|
+
let(:context) { TestFactories::Context.context }
|
20
|
+
let(:resource) { TestFactories::Resource.facts_resource(context.subject) }
|
21
|
+
let(:resource_array) { [context, resource]}
|
22
22
|
|
23
23
|
describe 'create a graph' do
|
24
24
|
it 'does not fail' do
|
@@ -32,12 +32,12 @@ module Dbd
|
|
32
32
|
subject << data_fact
|
33
33
|
end
|
34
34
|
|
35
|
-
it 'a
|
36
|
-
subject <<
|
35
|
+
it 'a context_fact does not fail' do
|
36
|
+
subject << context_fact_1
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'two facts does not fail' do
|
40
|
-
subject <<
|
40
|
+
subject << context_fact_1
|
41
41
|
subject << data_fact
|
42
42
|
end
|
43
43
|
|
@@ -45,8 +45,8 @@ module Dbd
|
|
45
45
|
lambda { subject << fact_no_subject } . should raise_error FactError
|
46
46
|
end
|
47
47
|
|
48
|
-
it 'fact with missing
|
49
|
-
lambda { subject <<
|
48
|
+
it 'fact with missing context raises FactError' do
|
49
|
+
lambda { subject << fact_no_context } . should raise_error FactError
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -88,22 +88,22 @@ module Dbd
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
describe 'a
|
91
|
+
describe 'a Context and a Resource' do
|
92
92
|
|
93
93
|
it 'does not fail' do
|
94
|
-
subject <<
|
94
|
+
subject << context
|
95
95
|
end
|
96
96
|
|
97
|
-
it 'Adds the facts from the
|
98
|
-
subject <<
|
97
|
+
it 'Adds the facts from the context to the graph' do
|
98
|
+
subject << context
|
99
99
|
subject.size.should == 2
|
100
100
|
end
|
101
101
|
|
102
|
-
it 'Adds the facts from the
|
103
|
-
subject <<
|
102
|
+
it 'Adds the facts from the context and the resource to the graph' do
|
103
|
+
subject << context
|
104
104
|
subject << resource
|
105
105
|
subject.size.should == 4
|
106
|
-
subject.first.should be_a(
|
106
|
+
subject.first.should be_a(ContextFact)
|
107
107
|
subject.last.class.should == Fact
|
108
108
|
end
|
109
109
|
end
|
@@ -113,9 +113,9 @@ module Dbd
|
|
113
113
|
subject << resource_array
|
114
114
|
end
|
115
115
|
|
116
|
-
it 'Adds the facts from the
|
116
|
+
it 'Adds the facts from the context and the resource to the graph' do
|
117
117
|
subject << resource_array
|
118
|
-
subject.first.class.should ==
|
118
|
+
subject.first.class.should == ContextFact
|
119
119
|
subject.last.class.should == Fact
|
120
120
|
subject.size.should == 4
|
121
121
|
end
|
@@ -126,13 +126,13 @@ module Dbd
|
|
126
126
|
end
|
127
127
|
|
128
128
|
it 'works with different levels deep in 1 collection' do
|
129
|
-
subject << [
|
129
|
+
subject << [context, [[resource]]]
|
130
130
|
subject.size.should == 4
|
131
131
|
end
|
132
132
|
end
|
133
133
|
|
134
134
|
it 'returns self' do
|
135
|
-
(subject << TestFactories::Fact::Collection.
|
135
|
+
(subject << TestFactories::Fact::Collection.context_facts(new_subject)).should be_a(described_class)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|