Skip to content

Commit 55b3b72

Browse files
committed
Make using context or graph_name conditional on RDF::VERSION.
1 parent 0d7b9f3 commit 55b3b72

5 files changed

Lines changed: 34 additions & 52 deletions

File tree

lib/rdf/spec/enumerable.rb

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
context "when enumerating statements" do
7474
it {is_expected.to respond_to(:statements)}
75-
its(:statements) {is_expected.to be_an_enumerator}
75+
#its(:statements) {is_expected.to be_an_enumerator}
7676

7777
context "#statements" do
7878
specify {expect(subject.statements.to_a.size).to eq @statements.size}
@@ -131,7 +131,7 @@
131131
it {is_expected.to respond_to(:each_triple)}
132132
it {is_expected.to respond_to(:enum_triple)}
133133

134-
its(:triples) {is_expected.to be_an_enumerator}
134+
#its(:triples) {is_expected.to be_an_enumerator}
135135
context "#triples" do
136136
specify {expect(subject.triples.to_a.size).to eq @statements.size}
137137
specify {expect(subject.triples).to all(be_a_triple)}
@@ -175,7 +175,7 @@
175175
it {is_expected.to respond_to(:each_quad)}
176176
it {is_expected.to respond_to(:enum_quad)}
177177

178-
its(:quads) {is_expected.to be_an_enumerator}
178+
#its(:quads) {is_expected.to be_an_enumerator}
179179
context "#quads" do
180180
specify {expect(subject.quads.to_a.size).to eq @statements.size}
181181
specify {expect(subject.quads).to all(be_a_quad)}
@@ -222,13 +222,13 @@
222222
it {is_expected.to respond_to(:each_subject)}
223223
it {is_expected.to respond_to(:enum_subject)}
224224

225-
its(:subjects) {is_expected.to be_an_enumerator}
225+
#its(:subjects) {is_expected.to be_an_enumerator}
226226
context "#subjects" do
227227
subject { enumerable.subjects }
228228
specify {is_expected.to be_an_enumerator}
229229
specify {is_expected.to all(be_a_resource)}
230-
context ":unique => false" do
231-
subject { enumerable.subjects(:unique => false) }
230+
context "unique: false" do
231+
subject { enumerable.subjects(unique: false) }
232232
specify {is_expected.to be_an_enumerator}
233233
specify {is_expected.to all(be_a_resource)}
234234
end
@@ -273,13 +273,13 @@
273273
it {is_expected.to respond_to(:each_predicate)}
274274
it {is_expected.to respond_to(:enum_predicate)}
275275

276-
its(:predicates) {is_expected.to be_an_enumerator}
276+
#its(:predicates) {is_expected.to be_an_enumerator}
277277
context "#predicates" do
278278
subject { enumerable.predicates }
279279
specify {is_expected.to be_an_enumerator}
280280
specify {is_expected.to all(be_a_uri)}
281-
context ":unique => false" do
282-
subject { enumerable.predicates(:unique => false) }
281+
context "unique: false" do
282+
subject { enumerable.predicates(unique: false) }
283283
specify {is_expected.to be_an_enumerator}
284284
specify {is_expected.to all(be_a_uri)}
285285
end
@@ -320,13 +320,13 @@
320320
it {is_expected.to respond_to(:each_object)}
321321
it {is_expected.to respond_to(:enum_object)}
322322

323-
its(:objects) {is_expected.to be_an_enumerator}
323+
#its(:objects) {is_expected.to be_an_enumerator}
324324
context "#objects" do
325325
subject { enumerable.objects }
326326
specify {is_expected.to be_an_enumerator}
327327
specify {is_expected.to all(be_a_term)}
328-
context ":unique => false" do
329-
subject { enumerable.objects(:unique => false) }
328+
context "unique: false" do
329+
subject { enumerable.objects(unique: false) }
330330
specify {is_expected.to be_an_enumerator}
331331
specify {is_expected.to all(be_a_term)}
332332
end
@@ -363,7 +363,7 @@
363363
end
364364
end
365365

366-
context "when enumerating contexts" do
366+
context "when enumerating contexts", unless: RDF::VERSION.to_s >= "1.99" do
367367
it {is_expected.to respond_to(:contexts)}
368368
it {is_expected.to respond_to(:has_context?)}
369369
it {is_expected.to respond_to(:each_context)}
@@ -375,7 +375,7 @@
375375
specify {is_expected.to be_an_enumerator}
376376
specify {is_expected.to all(be_a_resource)}
377377
context "unique: false" do
378-
subject { enumerable.contexts(:unique => false) }
378+
subject { enumerable.contexts(unique: false) }
379379
specify {is_expected.to be_an_enumerator}
380380
specify {is_expected.to all(be_a_resource)}
381381
end
@@ -423,38 +423,41 @@
423423
describe "#each_graph" do
424424
subject { enumerable.each_graph }
425425
it {is_expected.to be_an_enumerator}
426-
specify {is_expected.to all(be_a_graph)} if @supports_context
426+
specify {is_expected.to all(be_a_graph)} if @supports_named_graphs
427+
specify {expect(subject.each_graph).to all(be_a_graph)}
428+
429+
it "has appropriate number of graphs" do
430+
graph_names = @statements.map { |s| s.graph_name }.uniq.compact
431+
expect(subject.each_graph.to_a.size).to eq (graph_names.size + 1)
432+
end if @supports_named_graphs
427433
end
428434

429435
describe "#enum_graph" do
430436
subject { enumerable.enum_graph }
431437
it {is_expected.to be_an_enumerator}
432438
it {is_expected.to be_countable}
433439
it "enumerates the same as #each_graph" do
434-
expect(subject.to_a).to include(*enumerable.each_graph.to_a) if @supports_context # expect with match problematic
440+
expect(subject.to_a).to include(*enumerable.each_graph.to_a) if @supports_named_graphs # expect with match problematic
435441
end
436442
end
437443
end
438444

439-
context "when enumerating graphs" do
445+
context "when enumerating graphs", if: RDF::VERSION.to_s >= "1.99" do
440446
it {is_expected.to respond_to(:graph_names)}
441447
it {is_expected.to respond_to(:has_graph?)}
442-
it {is_expected.to respond_to(:each_graph)}
443-
it {is_expected.to respond_to(:enum_graph)}
444448

445-
its(:graph_names) {is_expected.to be_a(Array)}
446449
describe "#graph_names" do
447450
subject { enumerable.graph_names }
448451
specify {is_expected.to be_a(Array)}
449452
specify {is_expected.to all(be_a_resource)}
450-
context ":unique => false" do
451-
subject { enumerable.graph_names(:unique => false) }
453+
context "unique: false" do
454+
subject { enumerable.graph_names(unique: false) }
452455
specify {is_expected.to be_a(Array)}
453456
specify {is_expected.to all(be_a_resource)}
454457
end
455458
end
456459

457-
it "should implement #has_graph?" do
460+
describe "#has_graph?" do
458461
if @supports_named_graphs
459462
@statements.each do |statement|
460463
if statement.has_graph?
@@ -465,27 +468,6 @@
465468
expect(enumerable).not_to have_graph(uri)
466469
end
467470
end
468-
469-
its(:each_graph) {is_expected.to be_an_enumerator}
470-
471-
describe "#each_graph" do
472-
let(:graph_names) {@statements.map { |s| s.graph_name }.uniq.compact}
473-
subject { enumerable.each_graph }
474-
it {is_expected.to be_an_enumerator}
475-
specify {expect(subject.each_graph).to all(be_a_graph)}
476-
it "has appropriate number of graphs" do
477-
expect(subject.each_graph.to_a.size).to eq (graph_names.size + 1)
478-
end if @supports_named_graphs
479-
end
480-
481-
describe "#enum_graph" do
482-
subject { enumerable.enum_graph }
483-
it {is_expected.to be_an_enumerator}
484-
it {is_expected.to be_countable}
485-
it "enumerates the same as #each_graph" do
486-
expect(subject.to_a).to include(*enumerable.each_graph.to_a)
487-
end if @supports_named_graphs # expect with match problematic
488-
end
489471
end
490472

491473
context "when converting" do

lib/rdf/spec/mutable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,14 @@
6464
is_expected.to have_subject(resource)
6565
end
6666

67-
it "is_expected.to load statements with a context override" do
67+
it "is_expected.to load statements with a context override", unless: RDF::VERSION.to_s >= "1.99" do
6868
skip("mutability and contextuality") unless (subject.mutable? && @supports_named_graphs)
6969
subject.load RDF::Spec::TRIPLES_FILE, context: graph_name
7070
is_expected.to have_context(graph_name)
7171
expect(subject.query(context: graph_name).size).to eq subject.size
7272
end
7373

74-
it "is_expected.to load statements with a graph_name override" do
74+
it "is_expected.to load statements with a graph_name override", if: RDF::VERSION.to_s >= "1.99" do
7575
skip("mutability and contextuality") unless (subject.mutable? && @supports_named_graphs)
7676
subject.load RDF::Spec::TRIPLES_FILE, graph_name: graph_name
7777
is_expected.to have_graph(graph_name)

lib/rdf/spec/queryable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
end
286286
end
287287

288-
context "with context" do
288+
context "with context", unless: RDF::VERSION.to_s >= "1.99" do
289289
it "returns statements from all contexts with no context" do
290290
pattern = RDF::Query::Pattern.new(nil, nil, nil, context: nil)
291291
solutions = []
@@ -321,7 +321,7 @@
321321
end
322322
end
323323

324-
context "with graph_name" do
324+
context "with graph_name", if: RDF::VERSION.to_s >= "1.99" do
325325
it "returns statements from all graphs with no graph_name" do
326326
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: nil)
327327
solutions = []

lib/rdf/spec/transaction.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
expect(this.graph).to eq g
1717
end
1818

19-
it "accepts a context" do
19+
it "accepts a context", unless: RDF::VERSION.to_s >= "1.99" do
2020
c = double("context")
2121
this = subject.new(:graph => c)
2222
expect(this.graph).to eq c
@@ -27,7 +27,7 @@
2727
expect(this.context).to eq c
2828
end
2929

30-
it "accepts a graph_name" do
30+
it "accepts a graph_name", if: RDF::VERSION.to_s >= "1.99" do
3131
c = double("graph_name")
3232
this = subject.new(:graph => c)
3333
expect(this.graph).to eq c

lib/rdf/spec/writable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
expect(subject.count).to eq 1
9999
end
100100

101-
it "is_expected.to treat statements with a different context as distinct" do
101+
it "is_expected.to treat statements with a different context as distinct", unless: RDF::VERSION.to_s >= "1.99" do
102102
skip("writability") unless subject.writable?
103103
s1 = statement.dup
104104
s1.context = nil
@@ -113,7 +113,7 @@
113113
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
114114
end
115115

116-
it "is_expected.to treat statements with a different graph_name as distinct" do
116+
it "is_expected.to treat statements with a different graph_name as distinct", if: RDF::VERSION.to_s >= "1.99" do
117117
skip("writability") unless subject.writable?
118118
s1 = statement.dup
119119
s1.graph_name = nil

0 commit comments

Comments
 (0)