Skip to content

Commit 1d792b4

Browse files
committed
Don't use valid? for enumerable not supporting validation.
1 parent 6db7728 commit 1d792b4

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

lib/rdf/spec/enumerable.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,24 @@ module RDF_Enumerable
2929
it {should respond_to(:supports?)}
3030

3131
describe "valid?" do
32-
it {should be_valid}
32+
it "reports validity" do
33+
if subject.supports?(:validity)
34+
should be_valid
35+
else
36+
expect {subject.valid?}.to raise_error(NotImplementedError)
37+
end
38+
end
3339

3440
it "returns false if any statement is invalid" do
3541
if subject.respond_to?(:<<) && (subject.writable? rescue true)
3642
s = RDF::Statement.from([nil, nil, nil])
37-
expect(s).not_to be_valid
38-
subject << s
39-
expect(subject).not_to be_valid
43+
if subject.supports?(:validity)
44+
expect(s).not_to be_valid
45+
subject << s
46+
expect(subject).not_to be_valid
47+
else
48+
expect {subject.valid?}.to raise_error(NotImplementedError)
49+
end
4050
else
4151
pending("can't add statement to immutable enumerable")
4252
end

0 commit comments

Comments
 (0)