Skip to content

Commit 444a51e

Browse files
committed
Change skips to conditionals to avoid output clutter.
1 parent 11f70f2 commit 444a51e

3 files changed

Lines changed: 135 additions & 124 deletions

File tree

lib/rdf/spec/enumerable.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
else
4949
expect {subject.valid?}.to raise_error(NotImplementedError)
5050
end
51-
else
52-
skip("can't add statement to immutable enumerable")
5351
end
5452
end
5553
end

lib/rdf/spec/mutable.rb

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,35 @@
4848
end
4949

5050
it "is_expected.to accept a string filename argument" do
51-
skip("mutability") unless subject.mutable?
52-
expect { subject.load(RDF::Spec::TRIPLES_FILE) }.not_to raise_error
51+
expect { subject.load(RDF::Spec::TRIPLES_FILE) }.not_to raise_error if subject.mutable?
5352
end
5453

5554
it "is_expected.to accept an optional hash argument" do
56-
skip("mutability") unless subject.mutable?
57-
expect { subject.load(RDF::Spec::TRIPLES_FILE, {}) }.not_to raise_error
55+
expect { subject.load(RDF::Spec::TRIPLES_FILE, {}) }.not_to raise_error if subject.mutable?
5856
end
5957

6058
it "is_expected.to load statements" do
61-
skip("mutability") unless subject.mutable?
62-
subject.load RDF::Spec::TRIPLES_FILE
63-
expect(subject.size).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
64-
is_expected.to have_subject(resource)
59+
if subject.mutable?
60+
subject.load RDF::Spec::TRIPLES_FILE
61+
expect(subject.size).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
62+
is_expected.to have_subject(resource)
63+
end
6564
end
6665

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

7474
it "is_expected.to load statements with a graph_name override", if: RDF::VERSION.to_s >= "1.99" do
75-
skip("mutability and contextuality") unless (subject.mutable? && @supports_named_graphs)
76-
subject.load RDF::Spec::TRIPLES_FILE, graph_name: graph_name
77-
is_expected.to have_graph(graph_name)
78-
expect(subject.query(graph_name: graph_name).size).to eq subject.size
75+
if subject.mutable? && @supports_named_graphs
76+
subject.load RDF::Spec::TRIPLES_FILE, graph_name: graph_name
77+
is_expected.to have_graph(graph_name)
78+
expect(subject.query(graph_name: graph_name).size).to eq subject.size
79+
end
7980
end
8081
end
8182

@@ -96,57 +97,60 @@
9697
end
9798

9899
it "is_expected.to not raise errors" do
99-
skip("mutability") unless subject.mutable?
100-
expect { subject.delete(@statements.first) }.not_to raise_error
100+
expect { subject.delete(@statements.first) }.not_to raise_error if subject.mutable?
101101
end
102102

103103
it "is_expected.to support deleting one statement at a time" do
104-
skip("mutability") unless subject.mutable?
105-
subject.delete(@statements.first)
106-
is_expected.not_to have_statement(@statements.first)
104+
if subject.mutable?
105+
subject.delete(@statements.first)
106+
is_expected.not_to have_statement(@statements.first)
107+
end
107108
end
108109

109110
it "is_expected.to support deleting multiple statements at a time" do
110-
skip("mutability") unless subject.mutable?
111-
subject.delete(*@statements)
112-
expect(subject.find { |s| subject.has_statement?(s) }).to be_nil
111+
if subject.mutable?
112+
subject.delete(*@statements)
113+
expect(subject.find { |s| subject.has_statement?(s) }).to be_nil
114+
end
113115
end
114116

115117
it "is_expected.to support wildcard deletions" do
116-
skip("mutability") unless subject.mutable?
117-
# nothing deleted
118-
require 'digest/sha1'
119-
count = subject.count
120-
subject.delete([nil, nil, Digest::SHA1.hexdigest(File.read(__FILE__))])
121-
is_expected.not_to be_empty
122-
expect(subject.count).to eq count
123-
124-
# everything deleted
125-
subject.delete([nil, nil, nil])
126-
is_expected.to be_empty
118+
if subject.mutable?
119+
# nothing deleted
120+
require 'digest/sha1'
121+
count = subject.count
122+
subject.delete([nil, nil, Digest::SHA1.hexdigest(File.read(__FILE__))])
123+
is_expected.not_to be_empty
124+
expect(subject.count).to eq count
125+
126+
# everything deleted
127+
subject.delete([nil, nil, nil])
128+
is_expected.to be_empty
129+
end
127130
end
128131

129132
it "is_expected.to only delete statements when the graph_name matches" do
130-
skip("mutability") unless subject.mutable?
131-
# Setup three statements identical except for graph_name
132-
count = subject.count + (@supports_named_graphs ? 3 : 1)
133-
s1 = RDF::Statement.new(resource, RDF::URI.new("urn:predicate:1"), RDF::URI.new("urn:object:1"))
134-
s2 = s1.dup
135-
s2.graph_name = RDF::URI.new("urn:graph_name:1")
136-
s3 = s1.dup
137-
s3.graph_name = RDF::URI.new("urn:graph_name:2")
138-
subject.insert(s1)
139-
subject.insert(s2)
140-
subject.insert(s3)
141-
expect(subject.count).to eq count
142-
143-
# Delete one by one
144-
subject.delete(s1)
145-
expect(subject.count).to eq count - (@supports_named_graphs ? 1 : 1)
146-
subject.delete(s2)
147-
expect(subject.count).to eq count - (@supports_named_graphs ? 2 : 1)
148-
subject.delete(s3)
149-
expect(subject.count).to eq count - (@supports_named_graphs ? 3 : 1)
133+
if subject.mutable?
134+
# Setup three statements identical except for graph_name
135+
count = subject.count + (@supports_named_graphs ? 3 : 1)
136+
s1 = RDF::Statement.new(resource, RDF::URI.new("urn:predicate:1"), RDF::URI.new("urn:object:1"))
137+
s2 = s1.dup
138+
s2.graph_name = RDF::URI.new("urn:graph_name:1")
139+
s3 = s1.dup
140+
s3.graph_name = RDF::URI.new("urn:graph_name:2")
141+
subject.insert(s1)
142+
subject.insert(s2)
143+
subject.insert(s3)
144+
expect(subject.count).to eq count
145+
146+
# Delete one by one
147+
subject.delete(s1)
148+
expect(subject.count).to eq count - (@supports_named_graphs ? 1 : 1)
149+
subject.delete(s2)
150+
expect(subject.count).to eq count - (@supports_named_graphs ? 2 : 1)
151+
subject.delete(s3)
152+
expect(subject.count).to eq count - (@supports_named_graphs ? 3 : 1)
153+
end
150154
end
151155
end
152156
end

lib/rdf/spec/writable.rb

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -20,112 +20,121 @@
2020

2121
describe "#<<" do
2222
it "inserts a reader" do
23-
skip("writability") unless subject.writable?
24-
reader = RDF::NTriples::Reader.new(File.open(filename)).to_a
25-
subject << reader
26-
is_expected.to have_statement(statement)
27-
expect(subject.count).to eq count
23+
if subject.writable?
24+
reader = RDF::NTriples::Reader.new(File.open(filename)).to_a
25+
subject << reader
26+
is_expected.to have_statement(statement)
27+
expect(subject.count).to eq count
28+
end
2829
end
2930

3031
it "inserts a graph" do
31-
skip("writability") unless subject.writable?
32-
graph = RDF::Graph.new << statements
33-
subject << graph
34-
is_expected.to have_statement(statement)
35-
expect(subject.count).to eq count
32+
if subject.writable?
33+
graph = RDF::Graph.new << statements
34+
subject << graph
35+
is_expected.to have_statement(statement)
36+
expect(subject.count).to eq count
37+
end
3638
end
3739

3840
it "inserts an enumerable" do
39-
skip("writability") unless subject.writable?
40-
enumerable = statements.dup.extend(RDF::Enumerable)
41-
subject << enumerable
42-
is_expected.to have_statement(statement)
43-
expect(subject.count).to eq count
41+
if subject.writable?
42+
enumerable = statements.dup.extend(RDF::Enumerable)
43+
subject << enumerable
44+
is_expected.to have_statement(statement)
45+
expect(subject.count).to eq count
46+
end
4447
end
4548

4649
it "inserts data responding to #to_rdf" do
47-
skip("writability") unless subject.writable?
48-
mock = double('mock')
49-
allow(mock).to receive(:to_rdf).and_return(statements)
50-
subject << mock
51-
is_expected.to have_statement(statement)
52-
expect(subject.count).to eq count
50+
if subject.writable?
51+
mock = double('mock')
52+
allow(mock).to receive(:to_rdf).and_return(statements)
53+
subject << mock
54+
is_expected.to have_statement(statement)
55+
expect(subject.count).to eq count
56+
end
5357
end
5458

5559
it "inserts a statement" do
56-
skip("writability") unless subject.writable?
57-
subject << statement
58-
is_expected.to have_statement(statement)
59-
expect(subject.count).to eq 1
60+
if subject.writable?
61+
subject << statement
62+
is_expected.to have_statement(statement)
63+
expect(subject.count).to eq 1
64+
end
6065
end
6166
end
6267

6368
context "when inserting statements" do
6469
it "is_expected.to support #insert" do
65-
skip("writability") unless subject.writable?
66-
is_expected.to respond_to(:insert)
70+
is_expected.to respond_to(:insert) if subject.writable?
6771
end
6872

6973
it "is_expected.to not raise errors" do
70-
skip("writability") unless subject.writable?
71-
expect { subject.insert(statement) }.not_to raise_error
74+
expect { subject.insert(statement) }.not_to raise_error if subject.writable?
7275
end
7376

7477
it "is_expected.to support inserting one statement at a time" do
75-
skip("writability") unless subject.writable?
76-
subject.insert(statement)
77-
is_expected.to have_statement(statement)
78+
if subject.writable?
79+
subject.insert(statement)
80+
is_expected.to have_statement(statement)
81+
end
7882
end
7983

8084
it "is_expected.to support inserting multiple statements at a time" do
81-
skip("writability") unless subject.writable?
82-
subject.insert(*statements)
83-
statements.each do |statement|
84-
is_expected.to have_statement(statement) unless statement.to_a.any?(&:node?)
85+
if subject.writable?
86+
subject.insert(*statements)
87+
statements.each do |statement|
88+
is_expected.to have_statement(statement) unless statement.to_a.any?(&:node?)
89+
end
8590
end
8691
end
8792

8893
it "is_expected.to insert statements successfully" do
89-
skip("writability") unless subject.writable?
90-
subject.insert(*statements)
91-
expect(subject.count).to eq count
94+
if subject.writable?
95+
subject.insert(*statements)
96+
expect(subject.count).to eq count
97+
end
9298
end
9399

94100
it "is_expected.to not insert a statement twice" do
95-
skip("writability") unless subject.writable?
96-
subject.insert(statement)
97-
subject.insert(statement)
98-
expect(subject.count).to eq 1
101+
if subject.writable?
102+
subject.insert(statement)
103+
subject.insert(statement)
104+
expect(subject.count).to eq 1
105+
end
99106
end
100107

101108
it "is_expected.to treat statements with a different context as distinct", unless: RDF::VERSION.to_s >= "1.99" do
102-
skip("writability") unless subject.writable?
103-
s1 = statement.dup
104-
s1.context = nil
105-
s2 = statement.dup
106-
s2.context = RDF::URI.new("urn:context:1")
107-
s3 = statement.dup
108-
s3.context = RDF::URI.new("urn:context:2")
109-
subject.insert(s1)
110-
subject.insert(s2)
111-
subject.insert(s3)
112-
# If contexts are not suported, all three are redundant
113-
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
109+
if subject.writable?
110+
s1 = statement.dup
111+
s1.context = nil
112+
s2 = statement.dup
113+
s2.context = RDF::URI.new("urn:context:1")
114+
s3 = statement.dup
115+
s3.context = RDF::URI.new("urn:context:2")
116+
subject.insert(s1)
117+
subject.insert(s2)
118+
subject.insert(s3)
119+
# If contexts are not suported, all three are redundant
120+
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
121+
end
114122
end
115123

116124
it "is_expected.to treat statements with a different graph_name as distinct", if: RDF::VERSION.to_s >= "1.99" do
117-
skip("writability") unless subject.writable?
118-
s1 = statement.dup
119-
s1.graph_name = nil
120-
s2 = statement.dup
121-
s2.graph_name = RDF::URI.new("urn:context:1")
122-
s3 = statement.dup
123-
s3.graph_name = RDF::URI.new("urn:context:2")
124-
subject.insert(s1)
125-
subject.insert(s2)
126-
subject.insert(s3)
127-
# If graph_names are not suported, all three are redundant
128-
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
125+
if subject.writable?
126+
s1 = statement.dup
127+
s1.graph_name = nil
128+
s2 = statement.dup
129+
s2.graph_name = RDF::URI.new("urn:context:1")
130+
s3 = statement.dup
131+
s3.graph_name = RDF::URI.new("urn:context:2")
132+
subject.insert(s1)
133+
subject.insert(s2)
134+
subject.insert(s3)
135+
# If graph_names are not suported, all three are redundant
136+
expect(subject.count).to eq (supports_graph_name ? 3 : 1)
137+
end
129138
end
130139
end
131140
end

0 commit comments

Comments
 (0)