rdf-spec 1.1.13 → 1.99.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rdf/spec.rb +1 -0
- data/lib/rdf/spec/countable.rb +11 -11
- data/lib/rdf/spec/durable.rb +6 -6
- data/lib/rdf/spec/enumerable.rb +170 -148
- data/lib/rdf/spec/format.rb +3 -3
- data/lib/rdf/spec/http_adapter.rb +28 -6
- data/lib/rdf/spec/indexable.rb +6 -8
- data/lib/rdf/spec/inferable.rb +1 -1
- data/lib/rdf/spec/inspects.rb +71 -0
- data/lib/rdf/spec/literal.rb +7 -6
- data/lib/rdf/spec/matchers.rb +21 -0
- data/lib/rdf/spec/mutable.rb +85 -73
- data/lib/rdf/spec/queryable.rb +73 -41
- data/lib/rdf/spec/reader.rb +20 -20
- data/lib/rdf/spec/transaction.rb +24 -13
- data/lib/rdf/spec/writable.rb +97 -63
- data/lib/rdf/spec/writer.rb +18 -18
- data/spec/spec_helper.rb +2 -2
- data/spec/version_spec.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f20ea6160511bc458dbf138ed1fe61d828f1d40
|
4
|
+
data.tar.gz: 03830cb0bc7e6322ed30a39a9938a64be387728c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd8eb7f3e272f487d4f1114a4df4cc68b061e81f36cb4b3355578d6b254ce92efa1f1e8304aae27191c35383221212f430e95cb2c747b285273c85331fc0be92
|
7
|
+
data.tar.gz: 83afd3996484fcec39368ece2024c2ba15f04ec6bcb213ddd59f817816eead5fe124493b54c2d52b22dd4c481598d6f7f78de7c204d661cae53b286365c58e13
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.99.0
|
data/lib/rdf/spec.rb
CHANGED
data/lib/rdf/spec/countable.rb
CHANGED
@@ -24,22 +24,22 @@ RSpec.shared_examples 'an RDF::Countable' do
|
|
24
24
|
describe RDF::Countable do
|
25
25
|
subject {countable}
|
26
26
|
|
27
|
-
it {
|
28
|
-
it {
|
29
|
-
it {
|
30
|
-
its(:count) {
|
31
|
-
it {
|
32
|
-
its(:size) {
|
27
|
+
it {is_expected.to respond_to(:empty?)}
|
28
|
+
it {is_expected.to_not be_empty}
|
29
|
+
it {is_expected.to respond_to(:count)}
|
30
|
+
its(:count) {is_expected.to eq @statements.size}
|
31
|
+
it {is_expected.to respond_to(:size)}
|
32
|
+
its(:size) {is_expected.to eq @statements.size}
|
33
33
|
|
34
34
|
context "when empty" do
|
35
35
|
subject {[].extend(RDF::Countable)}
|
36
|
-
it {
|
37
|
-
its(:count) {
|
38
|
-
its(:size) {
|
36
|
+
it {is_expected.to be_empty}
|
37
|
+
its(:count) {is_expected.to eq 0}
|
38
|
+
its(:size) {is_expected.to eq 0}
|
39
39
|
end
|
40
40
|
|
41
|
-
its(:to_enum) {
|
42
|
-
its(:enum_for) {
|
41
|
+
its(:to_enum) {is_expected.to be_countable}
|
42
|
+
its(:enum_for) {is_expected.to be_countable}
|
43
43
|
it "#enum_for(:each)" do
|
44
44
|
expect(subject.enum_for(:each)).to be_countable
|
45
45
|
end
|
data/lib/rdf/spec/durable.rb
CHANGED
@@ -27,21 +27,21 @@ RSpec.shared_examples 'an RDF::Durable' do
|
|
27
27
|
|
28
28
|
subject {@load_durable.call}
|
29
29
|
|
30
|
-
it {
|
30
|
+
it { is_expected.to respond_to(:durable?) }
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "is_expected.to support #durable?" do
|
33
33
|
expect([true,false]).to be_member(subject.durable?)
|
34
34
|
end
|
35
35
|
|
36
|
-
it {
|
36
|
+
it {is_expected.to respond_to(:nondurable?)}
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "is_expected.to support #nondurable?" do
|
39
39
|
expect([true,false]).to be_member(@load_durable.call.nondurable?)
|
40
40
|
end
|
41
41
|
|
42
|
-
its(:nondurable?) {
|
42
|
+
its(:nondurable?) {is_expected.to_not eq subject.durable?}
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "is_expected.to save contents between instantiations" do
|
45
45
|
if subject.durable?
|
46
46
|
subject.load(RDF::Spec::TRIPLES_FILE)
|
47
47
|
expect(subject.count).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
|
data/lib/rdf/spec/enumerable.rb
CHANGED
@@ -19,7 +19,7 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
@
|
22
|
+
@supports_named_graphs = enumerable.supports?(:graph_name) rescue true
|
23
23
|
end
|
24
24
|
|
25
25
|
let(:subject_count) {@statements.map(&:subject).uniq.length}
|
@@ -27,12 +27,12 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
27
27
|
let(:non_bnode_statements) {@statements.reject {|s| s.subject.node? || s.object.node?}}
|
28
28
|
|
29
29
|
subject { enumerable }
|
30
|
-
it {
|
30
|
+
it {is_expected.to respond_to(:supports?)}
|
31
31
|
|
32
32
|
describe "valid?" do
|
33
33
|
it "reports validity" do
|
34
34
|
if subject.supports?(:validity)
|
35
|
-
|
35
|
+
is_expected.to be_valid
|
36
36
|
else
|
37
37
|
expect {subject.valid?}.to raise_error(NotImplementedError)
|
38
38
|
end
|
@@ -40,131 +40,127 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
40
40
|
|
41
41
|
it "returns false if any statement is invalid" do
|
42
42
|
if subject.respond_to?(:<<) && (subject.writable? rescue true)
|
43
|
-
s = RDF::Statement.
|
43
|
+
s = RDF::Statement(RDF::URI("http://rubygems.org/gems/rdf"), RDF::Literal("literal"), RDF::URI("http://ar.to/#self"))
|
44
44
|
if subject.supports?(:validity)
|
45
45
|
expect(s).not_to be_valid
|
46
46
|
subject << s
|
47
|
-
|
47
|
+
is_expected.not_to be_valid
|
48
48
|
else
|
49
49
|
expect {subject.valid?}.to raise_error(NotImplementedError)
|
50
50
|
end
|
51
|
-
else
|
52
|
-
skip("can't add statement to immutable enumerable")
|
53
51
|
end
|
54
52
|
end
|
55
53
|
end
|
56
54
|
|
57
55
|
context "when counting statements" do
|
58
|
-
it {
|
59
|
-
it {
|
60
|
-
it {
|
61
|
-
its(:count) {
|
62
|
-
it {
|
63
|
-
its(:size) {
|
56
|
+
it {is_expected.to respond_to(:empty?)}
|
57
|
+
it {is_expected.to_not be_empty}
|
58
|
+
it {is_expected.to respond_to(:count)}
|
59
|
+
its(:count) {is_expected.to eq @statements.size}
|
60
|
+
it {is_expected.to respond_to(:size)}
|
61
|
+
its(:size) {is_expected.to eq @statements.size}
|
64
62
|
|
65
63
|
context "and empty" do
|
66
64
|
subject {[].extend(RDF::Enumerable)}
|
67
|
-
it {
|
68
|
-
its(:count) {
|
69
|
-
its(:size) {
|
65
|
+
it {is_expected.to be_empty}
|
66
|
+
its(:count) {is_expected.to eq 0}
|
67
|
+
its(:size) {is_expected.to eq 0}
|
70
68
|
end
|
71
69
|
end
|
72
70
|
|
73
71
|
context "when enumerating statements" do
|
74
|
-
it {
|
75
|
-
its(:statements) {
|
72
|
+
it {is_expected.to respond_to(:statements)}
|
73
|
+
#its(:statements) {is_expected.to be_an_enumerator}
|
76
74
|
|
77
75
|
context "#statements" do
|
78
76
|
specify {expect(subject.statements.to_a.size).to eq @statements.size}
|
79
|
-
specify {subject.statements
|
77
|
+
specify {expect(subject.statements).to all(be_a_statement)}
|
80
78
|
end
|
81
79
|
|
82
|
-
it {
|
80
|
+
it {is_expected.to respond_to(:has_statement?)}
|
83
81
|
context "#has_statement?" do
|
84
82
|
let(:unknown_statement) {RDF::Statement.new(RDF::Node.new, RDF::URI.new("http://example.org/unknown"), RDF::Node.new)}
|
85
83
|
it "should have all statements" do
|
86
84
|
# Don't check for BNodes, as equivalence depends on their being exactly the same, not just the same identifier. If subject is loaded separately, these won't match.
|
87
85
|
non_bnode_statements.each do |statement|
|
88
|
-
|
86
|
+
is_expected.to have_statement(statement)
|
89
87
|
end
|
90
88
|
end
|
91
89
|
|
92
|
-
it "does not have statement in different
|
93
|
-
if @
|
94
|
-
|
90
|
+
it "does not have statement in different named graph" do
|
91
|
+
if @supports_named_graphs
|
92
|
+
graph_name = RDF::URI.new("urn:graph_name:1")
|
95
93
|
non_bnode_statements.each do |statement|
|
96
94
|
s = statement.dup
|
97
|
-
s.
|
98
|
-
|
95
|
+
s.graph_name = graph_name
|
96
|
+
is_expected.not_to have_statement(s)
|
99
97
|
end
|
100
98
|
end
|
101
99
|
end
|
102
100
|
|
103
101
|
it "does not have an unknown statement" do
|
104
|
-
|
102
|
+
is_expected.not_to have_statement(unknown_statement)
|
105
103
|
end
|
106
104
|
end
|
107
105
|
|
108
|
-
it {
|
109
|
-
its(:each_statement) {
|
110
|
-
|
111
|
-
subject.each_statement { |statement| expect(statement).to be_a_statement }
|
112
|
-
end
|
106
|
+
it {is_expected.to respond_to(:each_statement)}
|
107
|
+
its(:each_statement) {is_expected.to be_an_enumerator}
|
108
|
+
its(:each_statement) {expect(subject.each_statement).to all(be_a_statement)}
|
113
109
|
|
114
|
-
it {
|
115
|
-
its(:enum_statement) {
|
116
|
-
its(:enum_statement) {
|
117
|
-
its(:enum_statement) {
|
118
|
-
its(:enum_statement) {
|
110
|
+
it {is_expected.to respond_to(:enum_statement)}
|
111
|
+
its(:enum_statement) {is_expected.to be_an_enumerator}
|
112
|
+
its(:enum_statement) {is_expected.to be_countable}
|
113
|
+
its(:enum_statement) {is_expected.to be_enumerable}
|
114
|
+
its(:enum_statement) {is_expected.to be_queryable}
|
119
115
|
context "#enum_statement" do
|
120
116
|
it "should enumerate all statements" do
|
121
117
|
expect(subject.enum_statement.count).to eq enumerable.each_statement.count
|
122
118
|
subject.enum_statement.each do |s|
|
123
119
|
expect(s).to be_a_statement
|
124
|
-
expect(enumerable.each_statement.to_a).to include(s) unless s.
|
120
|
+
expect(enumerable.each_statement.to_a).to include(s) unless s.node?
|
125
121
|
end
|
126
122
|
end
|
127
123
|
end
|
128
124
|
end
|
129
125
|
|
130
126
|
context "when enumerating triples" do
|
131
|
-
it {
|
132
|
-
it {
|
133
|
-
it {
|
134
|
-
it {
|
127
|
+
it {is_expected.to respond_to(:triples)}
|
128
|
+
it {is_expected.to respond_to(:has_triple?)}
|
129
|
+
it {is_expected.to respond_to(:each_triple)}
|
130
|
+
it {is_expected.to respond_to(:enum_triple)}
|
135
131
|
|
136
|
-
its(:triples) {
|
132
|
+
#its(:triples) {is_expected.to be_an_enumerator}
|
137
133
|
context "#triples" do
|
138
134
|
specify {expect(subject.triples.to_a.size).to eq @statements.size}
|
139
|
-
specify {subject.triples
|
135
|
+
specify {expect(subject.triples).to all(be_a_triple)}
|
140
136
|
end
|
141
137
|
|
142
138
|
context "#has_triple?" do
|
143
139
|
specify do
|
144
140
|
non_bnode_statements.each do |statement|
|
145
|
-
|
141
|
+
is_expected.to have_triple(statement.to_triple)
|
146
142
|
end
|
147
143
|
end
|
148
144
|
end
|
149
145
|
|
150
|
-
its(:each_triple) {
|
146
|
+
its(:each_triple) {is_expected.to be_an_enumerator}
|
151
147
|
context "#each_triple" do
|
152
|
-
specify {subject.each_triple
|
148
|
+
specify {expect(subject.each_triple).to all(be_a_triple)}
|
153
149
|
it "should iterate over all triples" do
|
154
150
|
subject.each_triple do |*triple|
|
155
|
-
triple.each
|
151
|
+
expect(triple.each).to all(be_a_term)
|
156
152
|
expect(enumerable).to have_triple(triple) unless triple.any?(&:node?)
|
157
153
|
end
|
158
154
|
end
|
159
155
|
end
|
160
156
|
|
161
|
-
its(:enum_triple) {
|
162
|
-
its(:enum_triple) {
|
157
|
+
its(:enum_triple) {is_expected.to be_an_enumerator}
|
158
|
+
its(:enum_triple) {is_expected.to be_countable}
|
163
159
|
context "#enum_triple" do
|
164
160
|
it "should enumerate all triples" do
|
165
161
|
expect(subject.enum_triple.count).to eq enumerable.each_triple.count
|
166
162
|
subject.enum_triple.each do |s, p, o|
|
167
|
-
[s, p, o]
|
163
|
+
expect([s, p, o]).to all(be_a_term)
|
168
164
|
expect(enumerable).to have_triple([s, p, o]) unless [s, p, o].any?(&:node?)
|
169
165
|
end
|
170
166
|
end
|
@@ -172,45 +168,45 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
172
168
|
end
|
173
169
|
|
174
170
|
context "when enumerating quads" do
|
175
|
-
it {
|
176
|
-
it {
|
177
|
-
it {
|
178
|
-
it {
|
171
|
+
it {is_expected.to respond_to(:quads)}
|
172
|
+
it {is_expected.to respond_to(:has_quad?)}
|
173
|
+
it {is_expected.to respond_to(:each_quad)}
|
174
|
+
it {is_expected.to respond_to(:enum_quad)}
|
179
175
|
|
180
|
-
its(:quads) {
|
176
|
+
#its(:quads) {is_expected.to be_an_enumerator}
|
181
177
|
context "#quads" do
|
182
178
|
specify {expect(subject.quads.to_a.size).to eq @statements.size}
|
183
|
-
specify {subject.quads
|
179
|
+
specify {expect(subject.quads).to all(be_a_quad)}
|
184
180
|
end
|
185
181
|
|
186
182
|
context "#has_quad?" do
|
187
183
|
specify do
|
188
|
-
if @
|
184
|
+
if @supports_named_graphs
|
189
185
|
non_bnode_statements.each do |statement|
|
190
|
-
|
186
|
+
is_expected.to have_quad(statement.to_quad)
|
191
187
|
end
|
192
188
|
end
|
193
189
|
end
|
194
190
|
end
|
195
191
|
|
196
|
-
its(:each_quad) {
|
192
|
+
its(:each_quad) {is_expected.to be_an_enumerator}
|
197
193
|
context "#each_quad" do
|
198
|
-
specify {subject.each_quad
|
194
|
+
specify {expect(subject.each_quad).to all(be_a_quad)}
|
199
195
|
it "should iterate over all quads" do
|
200
196
|
subject.each_quad do |*quad|
|
201
|
-
quad.compact
|
197
|
+
expect(quad.compact).to all(be_a_term)
|
202
198
|
expect(enumerable).to have_quad(quad) unless quad.compact.any?(&:node?)
|
203
199
|
end
|
204
200
|
end
|
205
201
|
end
|
206
202
|
|
207
|
-
its(:enum_quad) {
|
208
|
-
its(:enum_quad) {
|
203
|
+
its(:enum_quad) {is_expected.to be_an_enumerator}
|
204
|
+
its(:enum_quad) {is_expected.to be_countable}
|
209
205
|
context "#enum_quad" do
|
210
206
|
it "should enumerate all quads" do
|
211
207
|
expect(subject.enum_quad.count).to eq enumerable.each_quad.count
|
212
208
|
subject.enum_quad.each do |s, p, o, c|
|
213
|
-
[s, p, o, c].compact
|
209
|
+
expect([s, p, o, c].compact).to all(be_a_term)
|
214
210
|
expect(enumerable).to have_quad([s, p, o, c]) unless [s, p, o].any?(&:node?)
|
215
211
|
end
|
216
212
|
end
|
@@ -219,20 +215,20 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
219
215
|
|
220
216
|
context "when enumerating subjects" do
|
221
217
|
let(:subjects) {subject.map { |s| s.subject }.reject(&:node?).uniq}
|
222
|
-
it {
|
223
|
-
it {
|
224
|
-
it {
|
225
|
-
it {
|
218
|
+
it {is_expected.to respond_to(:subjects)}
|
219
|
+
it {is_expected.to respond_to(:has_subject?)}
|
220
|
+
it {is_expected.to respond_to(:each_subject)}
|
221
|
+
it {is_expected.to respond_to(:enum_subject)}
|
226
222
|
|
227
|
-
its(:subjects) {
|
223
|
+
#its(:subjects) {is_expected.to be_an_enumerator}
|
228
224
|
context "#subjects" do
|
229
225
|
subject { enumerable.subjects }
|
230
|
-
specify {
|
231
|
-
specify {
|
232
|
-
context ":
|
233
|
-
subject { enumerable.subjects(:
|
234
|
-
specify {
|
235
|
-
specify {
|
226
|
+
specify {is_expected.to be_an_enumerator}
|
227
|
+
specify {is_expected.to all(be_a_resource)}
|
228
|
+
context "unique: false" do
|
229
|
+
subject { enumerable.subjects(unique: false) }
|
230
|
+
specify {is_expected.to be_an_enumerator}
|
231
|
+
specify {is_expected.to all(be_a_resource)}
|
236
232
|
end
|
237
233
|
end
|
238
234
|
|
@@ -248,15 +244,15 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
248
244
|
end
|
249
245
|
end
|
250
246
|
|
251
|
-
its(:each_subject) {
|
247
|
+
its(:each_subject) {is_expected.to be_an_enumerator}
|
252
248
|
context "#each_subject" do
|
253
249
|
specify {expect(subject.each_subject.reject(&:node?).size).to eq subjects.reject(&:node?).size}
|
254
|
-
specify {subject.each_subject
|
250
|
+
specify {expect(subject.each_subject).to all(be_a_resource)}
|
255
251
|
specify {subject.each_subject {|value| expect(subjects).to include(value) unless value.node?}}
|
256
252
|
end
|
257
253
|
|
258
|
-
its(:enum_subject) {
|
259
|
-
its(:enum_subject) {
|
254
|
+
its(:enum_subject) {is_expected.to be_an_enumerator}
|
255
|
+
its(:enum_subject) {is_expected.to be_countable}
|
260
256
|
context "#enum_subject" do
|
261
257
|
specify {expect(subject.enum_subject.to_a.reject(&:node?).size).to eq subjects.reject(&:node?).size}
|
262
258
|
it "should enumerate all subjects" do
|
@@ -270,20 +266,20 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
270
266
|
|
271
267
|
context "when enumerating predicates" do
|
272
268
|
let(:predicates) {@statements.map { |s| s.predicate }.uniq}
|
273
|
-
it {
|
274
|
-
it {
|
275
|
-
it {
|
276
|
-
it {
|
269
|
+
it {is_expected.to respond_to(:predicates)}
|
270
|
+
it {is_expected.to respond_to(:has_predicate?)}
|
271
|
+
it {is_expected.to respond_to(:each_predicate)}
|
272
|
+
it {is_expected.to respond_to(:enum_predicate)}
|
277
273
|
|
278
|
-
its(:predicates) {
|
274
|
+
#its(:predicates) {is_expected.to be_an_enumerator}
|
279
275
|
context "#predicates" do
|
280
276
|
subject { enumerable.predicates }
|
281
|
-
specify {
|
282
|
-
specify {
|
283
|
-
context ":
|
284
|
-
subject { enumerable.predicates(:
|
285
|
-
specify {
|
286
|
-
specify {
|
277
|
+
specify {is_expected.to be_an_enumerator}
|
278
|
+
specify {is_expected.to all(be_a_uri)}
|
279
|
+
context "unique: false" do
|
280
|
+
subject { enumerable.predicates(unique: false) }
|
281
|
+
specify {is_expected.to be_an_enumerator}
|
282
|
+
specify {is_expected.to all(be_a_uri)}
|
287
283
|
end
|
288
284
|
end
|
289
285
|
|
@@ -299,15 +295,15 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
299
295
|
end
|
300
296
|
end
|
301
297
|
|
302
|
-
its(:each_predicate) {
|
298
|
+
its(:each_predicate) {is_expected.to be_an_enumerator}
|
303
299
|
context "#each_predicate" do
|
304
300
|
specify {expect(subject.each_predicate.to_a.size).to eq predicates.size}
|
305
|
-
specify {subject.each_predicate
|
301
|
+
specify {expect(subject.each_predicate).to all(be_a_uri)}
|
306
302
|
specify {subject.each_predicate {|value| expect(predicates).to include(value)}}
|
307
303
|
end
|
308
304
|
|
309
|
-
its(:enum_predicate) {
|
310
|
-
its(:enum_predicate) {
|
305
|
+
its(:enum_predicate) {is_expected.to be_an_enumerator}
|
306
|
+
its(:enum_predicate) {is_expected.to be_countable}
|
311
307
|
context "#enum_predicate" do
|
312
308
|
it "should enumerate all predicates" do
|
313
309
|
expect(subject.enum_predicate.to_a).to include(*predicates)
|
@@ -317,20 +313,20 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
317
313
|
|
318
314
|
context "when enumerating objects" do
|
319
315
|
let(:objects) {subject.map(&:object).reject(&:node?).uniq}
|
320
|
-
it {
|
321
|
-
it {
|
322
|
-
it {
|
323
|
-
it {
|
316
|
+
it {is_expected.to respond_to(:objects)}
|
317
|
+
it {is_expected.to respond_to(:has_object?)}
|
318
|
+
it {is_expected.to respond_to(:each_object)}
|
319
|
+
it {is_expected.to respond_to(:enum_object)}
|
324
320
|
|
325
|
-
its(:objects) {
|
321
|
+
#its(:objects) {is_expected.to be_an_enumerator}
|
326
322
|
context "#objects" do
|
327
323
|
subject { enumerable.objects }
|
328
|
-
specify {
|
329
|
-
specify {
|
330
|
-
context ":
|
331
|
-
subject { enumerable.objects(:
|
332
|
-
specify {
|
333
|
-
specify {
|
324
|
+
specify {is_expected.to be_an_enumerator}
|
325
|
+
specify {is_expected.to all(be_a_term)}
|
326
|
+
context "unique: false" do
|
327
|
+
subject { enumerable.objects(unique: false) }
|
328
|
+
specify {is_expected.to be_an_enumerator}
|
329
|
+
specify {is_expected.to all(be_a_term)}
|
334
330
|
end
|
335
331
|
end
|
336
332
|
|
@@ -346,15 +342,15 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
346
342
|
end
|
347
343
|
end
|
348
344
|
|
349
|
-
its(:each_object) {
|
345
|
+
its(:each_object) {is_expected.to be_an_enumerator}
|
350
346
|
context "#each_object" do
|
351
347
|
specify {expect(subject.each_object.reject(&:node?).size).to eq objects.size}
|
352
|
-
specify {subject.each_object
|
348
|
+
specify {expect(subject.each_object).to all(be_a_term)}
|
353
349
|
specify {subject.each_object {|value| expect(objects).to include(value) unless value.node?}}
|
354
350
|
end
|
355
351
|
|
356
|
-
its(:enum_object) {
|
357
|
-
its(:enum_object) {
|
352
|
+
its(:enum_object) {is_expected.to be_an_enumerator}
|
353
|
+
its(:enum_object) {is_expected.to be_countable}
|
358
354
|
context "#enum_object" do
|
359
355
|
it "should enumerate all objects" do
|
360
356
|
subject.enum_object.each do |o|
|
@@ -365,30 +361,26 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
365
361
|
end
|
366
362
|
end
|
367
363
|
|
368
|
-
context "when enumerating contexts" do
|
369
|
-
it {
|
370
|
-
it {
|
371
|
-
it {
|
372
|
-
it {
|
364
|
+
context "when enumerating contexts", unless: RDF::VERSION.to_s >= "1.99" do
|
365
|
+
it {is_expected.to respond_to(:contexts)}
|
366
|
+
it {is_expected.to respond_to(:has_context?)}
|
367
|
+
it {is_expected.to respond_to(:each_context)}
|
368
|
+
it {is_expected.to respond_to(:enum_context)}
|
373
369
|
|
374
|
-
its(:contexts) {
|
370
|
+
its(:contexts) {is_expected.to be_an_enumerator}
|
375
371
|
describe "#contexts" do
|
376
372
|
subject { enumerable.contexts }
|
377
|
-
specify {
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
specify {expect(subject).to be_an_enumerator}
|
384
|
-
it "values should be resources" do
|
385
|
-
subject.each { |value| expect(value).to be_a_resource }
|
386
|
-
end
|
373
|
+
specify {is_expected.to be_an_enumerator}
|
374
|
+
specify {is_expected.to all(be_a_resource)}
|
375
|
+
context "unique: false" do
|
376
|
+
subject { enumerable.contexts(unique: false) }
|
377
|
+
specify {is_expected.to be_an_enumerator}
|
378
|
+
specify {is_expected.to all(be_a_resource)}
|
387
379
|
end
|
388
380
|
end
|
389
381
|
|
390
|
-
it "
|
391
|
-
if @
|
382
|
+
it "is_expected.to implement #has_context?" do
|
383
|
+
if @supports_named_graphs
|
392
384
|
@statements.each do |statement|
|
393
385
|
if statement.has_context?
|
394
386
|
expect(enumerable).to have_context(statement.context)
|
@@ -399,24 +391,22 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
399
391
|
end
|
400
392
|
end
|
401
393
|
|
402
|
-
its(:each_context) {
|
394
|
+
its(:each_context) {is_expected.to be_an_enumerator}
|
403
395
|
context "#each_context" do
|
404
396
|
let(:contexts) {@statements.map { |s| s.context }.uniq.compact}
|
405
397
|
it "has appropriate number of contexts" do
|
406
|
-
if @
|
398
|
+
if @supports_named_graphs
|
407
399
|
expect(subject.each_context.to_a.size).to eq contexts.size
|
408
400
|
end
|
409
401
|
end
|
410
|
-
|
411
|
-
|
412
|
-
end
|
413
|
-
it "should have all contexts" do
|
402
|
+
specify {expect(subject.each_context).to all(be_a_resource)}
|
403
|
+
it "is_expected.to have all contexts" do
|
414
404
|
subject.each_context {|value| expect(contexts).to include(value)}
|
415
405
|
end
|
416
406
|
end
|
417
407
|
|
418
|
-
its(:enum_context) {
|
419
|
-
its(:enum_context) {
|
408
|
+
its(:enum_context) {is_expected.to be_an_enumerator}
|
409
|
+
its(:enum_context) {is_expected.to be_countable}
|
420
410
|
context "#enum_context" do
|
421
411
|
it "should enumerate all contexts" do
|
422
412
|
expect(subject.enum_context.to_a).to include(*enumerable.each_context.to_a)
|
@@ -425,30 +415,62 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
425
415
|
end
|
426
416
|
|
427
417
|
context "when enumerating graphs" do
|
428
|
-
it {
|
429
|
-
it {
|
418
|
+
it {is_expected.to respond_to(:each_graph)}
|
419
|
+
it {is_expected.to respond_to(:enum_graph)}
|
430
420
|
|
431
421
|
describe "#each_graph" do
|
432
422
|
subject { enumerable.each_graph }
|
433
|
-
it {
|
434
|
-
|
435
|
-
|
436
|
-
|
423
|
+
it {is_expected.to be_an_enumerator}
|
424
|
+
specify {is_expected.to all(be_a_graph)} if @supports_named_graphs
|
425
|
+
specify {expect(subject.each_graph).to all(be_a_graph)}
|
426
|
+
|
427
|
+
it "has appropriate number of graphs" do
|
428
|
+
graph_names = @statements.map { |s| s.graph_name }.uniq.compact
|
429
|
+
expect(subject.each_graph.to_a.size).to eq (graph_names.size + 1)
|
430
|
+
end if @supports_named_graphs
|
437
431
|
end
|
438
432
|
|
439
433
|
describe "#enum_graph" do
|
440
434
|
subject { enumerable.enum_graph }
|
441
|
-
it {
|
442
|
-
it {
|
435
|
+
it {is_expected.to be_an_enumerator}
|
436
|
+
it {is_expected.to be_countable}
|
443
437
|
it "enumerates the same as #each_graph" do
|
444
|
-
expect(subject.to_a).to include(*enumerable.each_graph.to_a) if @
|
438
|
+
expect(subject.to_a).to include(*enumerable.each_graph.to_a) if @supports_named_graphs # expect with match problematic
|
439
|
+
end
|
440
|
+
end
|
441
|
+
end
|
442
|
+
|
443
|
+
context "when enumerating graphs", if: RDF::VERSION.to_s >= "1.99" do
|
444
|
+
it {is_expected.to respond_to(:graph_names)}
|
445
|
+
it {is_expected.to respond_to(:has_graph?)}
|
446
|
+
|
447
|
+
describe "#graph_names" do
|
448
|
+
subject { enumerable.graph_names }
|
449
|
+
specify {is_expected.to be_a(Array)}
|
450
|
+
specify {is_expected.to all(be_a_resource)}
|
451
|
+
context "unique: false" do
|
452
|
+
subject { enumerable.graph_names(unique: false) }
|
453
|
+
specify {is_expected.to be_a(Array)}
|
454
|
+
specify {is_expected.to all(be_a_resource)}
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
describe "#has_graph?" do
|
459
|
+
if @supports_named_graphs
|
460
|
+
@statements.each do |statement|
|
461
|
+
if statement.has_graph?
|
462
|
+
expect(enumerable).to have_graph(statement.graph_name)
|
463
|
+
end
|
464
|
+
end
|
465
|
+
uri = RDF::URI.new('http://example.org/does/not/have/this/uri')
|
466
|
+
expect(enumerable).not_to have_graph(uri)
|
445
467
|
end
|
446
468
|
end
|
447
469
|
end
|
448
470
|
|
449
471
|
context "when converting" do
|
450
|
-
it {
|
451
|
-
its(:to_hash) {
|
472
|
+
it {is_expected.to respond_to(:to_hash)}
|
473
|
+
its(:to_hash) {is_expected.to be_instance_of(Hash)}
|
452
474
|
context "#to_hash" do
|
453
475
|
it "should have as many keys as subjects" do
|
454
476
|
expect(subject.to_hash.keys.size).to eq enumerable.subjects.to_a.size
|
@@ -457,7 +479,7 @@ RSpec.shared_examples 'an RDF::Enumerable' do
|
|
457
479
|
end
|
458
480
|
|
459
481
|
context "when dumping" do
|
460
|
-
it {
|
482
|
+
it {is_expected.to respond_to(:dump)}
|
461
483
|
|
462
484
|
it "should implement #dump" do
|
463
485
|
expect(subject.dump(:ntriples)).to eq RDF::NTriples::Writer.buffer() {|w| w << enumerable}
|