Skip to content

Commit b082691

Browse files
committed
Updates to support more strict Repository implementations:
* Don't expect a Writable instance to be able to insert an invalid statement. * When querying for intentionally failing patterns, ensure that they are legal RDF patterns, and don't depend on BNode identity. * Writer tests inserts a real triple, not nothing.
1 parent 63a3267 commit b082691

3 files changed

Lines changed: 6 additions & 14 deletions

File tree

lib/rdf/spec/mutable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module RDF_Mutable
8080
context "#from_{reader}" do
8181
it "should instantiate a reader" do
8282
reader = double("reader")
83-
expect(reader).to receive(:new).and_return(RDF::NTriples::Reader.new(""))
83+
expect(reader).to receive(:new).and_return(RDF::Spec.quads.first)
8484
expect(RDF::Reader).to receive(:for).with(:a_reader).and_return(reader)
8585
subject.send(:from_a_reader)
8686
end

lib/rdf/spec/queryable.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ module RDF_Queryable
317317
##
318318
# @see RDF::Queryable#first
319319
describe "#first" do
320-
let(:failing_pattern) {[RDF::Node.new] * 3}
320+
let(:failing_pattern) {[RDF::URI("http://no-such-resource"), RDF.type, RDF::Node.new]}
321321

322322
it "should respond to #first" do
323323
expect(subject).to respond_to(:first)
@@ -349,7 +349,7 @@ module RDF_Queryable
349349
##
350350
# @see RDF::Queryable#first_subject
351351
describe "#first_subject" do
352-
let(:failing_pattern) {[RDF::Node.new, nil, nil]}
352+
let(:failing_pattern) {[RDF::URI("http://no-such-resource"), nil, nil]}
353353

354354
it "should respond to #first_subject" do
355355
expect(subject).to respond_to(:first_subject)
@@ -361,7 +361,7 @@ module RDF_Queryable
361361
end
362362

363363
it "returns the correct value when the pattern matches" do
364-
matching_patterns = [[nil, nil, nil], [subject.first.subject, nil, nil]]
364+
matching_patterns = [[nil, nil, nil], [RDF::URI("http://rubygems.org/gems/rdf"), nil, nil]]
365365
matching_patterns.each do |matching_pattern|
366366
expect(subject.first_subject(matching_pattern)).to eq subject.query(matching_pattern).first.subject
367367
end
@@ -382,7 +382,7 @@ module RDF_Queryable
382382
# @see RDF::Queryable#first_predicate
383383

384384
describe "#first_predicate" do
385-
let(:failing_pattern) {[nil, RDF::Node.new, nil]}
385+
let(:failing_pattern) {[nil, RDF::URI("http://no-such-resource"), nil]}
386386

387387
it {should respond_to(:first_predicate)}
388388

@@ -413,7 +413,7 @@ module RDF_Queryable
413413
# @see RDF::Queryable#first_object
414414

415415
describe "#first_object" do
416-
let(:failing_pattern) {[nil, nil, RDF::Node.new]}
416+
let(:failing_pattern) {[nil, nil, RDF::URI("http://no-such-resource")]}
417417
it {should respond_to(:first_object)}
418418

419419
it "returns enurator without a pattern" do

lib/rdf/spec/writable.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@ module RDF_Writable
6161
expect(subject).to have_statement(statement)
6262
expect(subject.count).to eq 1
6363
end
64-
65-
it "inserts an invalid statement" do
66-
skip("writability") unless subject.writable?
67-
s = RDF::Statement.from([nil, nil, nil])
68-
expect(s).not_to be_valid
69-
subject << s
70-
expect(subject.count).to eq 1
71-
end
7264
end
7365

7466
context "when inserting statements" do

0 commit comments

Comments
 (0)