Skip to content

Commit c61a570

Browse files
committed
Updates for RSpec 3.0.
1 parent 7b2e6e1 commit c61a570

8 files changed

Lines changed: 122 additions & 142 deletions

File tree

lib/rdf/spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'rdf' # @see http://rubygems.org/gems/rdf
22
require 'rspec' # @see http://rubygems.org/gems/rspec
3+
require 'rspec/its'
34

45
module RDF
56
##

lib/rdf/spec/enumerable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ module RDF_Enumerable
439439
subject {@enumerable.enum_graph}
440440
it {should be_an_enumerator}
441441
it {should be_countable}
442-
it "enumerates the same as #each_graph", :pending => "graph inclusion issue" do
442+
it "enumerates the same as #each_graph" do
443443
expect(subject.to_a).to include(*@enumerable.each_graph.to_a) if @supports_context # expect with match problematic
444444
end
445445
end

lib/rdf/spec/mutable.rb

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,27 @@ module RDF_Mutable
5353
end
5454

5555
it "should accept a string filename argument" do
56-
pending("mutability", :unless => subject.mutable?) do
57-
expect { subject.load(RDF::Spec::TRIPLES_FILE) }.not_to raise_error
58-
end
56+
skip("mutability") unless subject.mutable?
57+
expect { subject.load(RDF::Spec::TRIPLES_FILE) }.not_to raise_error
5958
end
6059

6160
it "should accept an optional hash argument" do
62-
pending("mutability", :unless => subject.mutable?) do
63-
expect { subject.load(RDF::Spec::TRIPLES_FILE, {}) }.not_to raise_error
64-
end
61+
skip("mutability") unless subject.mutable?
62+
expect { subject.load(RDF::Spec::TRIPLES_FILE, {}) }.not_to raise_error
6563
end
6664

6765
it "should load statements" do
68-
pending("mutability", :unless => subject.mutable?) do
69-
subject.load RDF::Spec::TRIPLES_FILE
70-
expect(subject.size).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
71-
expect(subject).to have_subject(resource)
72-
end
66+
skip("mutability") unless subject.mutable?
67+
subject.load RDF::Spec::TRIPLES_FILE
68+
expect(subject.size).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
69+
expect(subject).to have_subject(resource)
7370
end
7471

7572
it "should load statements with a context override" do
76-
pending("mutability and contextuality", :unless => (subject.mutable? && @supports_context)) do
77-
subject.load RDF::Spec::TRIPLES_FILE, :context => context
78-
expect(subject).to have_context(context)
79-
expect(subject.query(:context => context).size).to eq subject.size
80-
end
73+
skip("mutability and contextuality") unless (subject.mutable? && @supports_context)
74+
subject.load RDF::Spec::TRIPLES_FILE, :context => context
75+
expect(subject).to have_context(context)
76+
expect(subject.query(:context => context).size).to eq subject.size
8177
end
8278
end
8379

@@ -97,62 +93,57 @@ module RDF_Mutable
9793
end
9894

9995
it "should not raise errors" do
100-
pending("mutability", :unless => subject.mutable?) do
101-
expect { subject.delete(@statements.first) }.not_to raise_error
102-
end
96+
skip("mutability") unless subject.mutable?
97+
expect { subject.delete(@statements.first) }.not_to raise_error
10398
end
10499

105100
it "should support deleting one statement at a time" do
106-
pending("mutability", :unless => subject.mutable?) do
107-
subject.delete(@statements.first)
108-
expect(subject).not_to have_statement(@statements.first)
109-
end
101+
skip("mutability") unless subject.mutable?
102+
subject.delete(@statements.first)
103+
expect(subject).not_to have_statement(@statements.first)
110104
end
111105

112106
it "should support deleting multiple statements at a time" do
113-
pending("mutability", :unless => subject.mutable?) do
114-
subject.delete(*@statements)
115-
expect(subject.find { |s| subject.has_statement?(s) }).to be_false
116-
end
107+
skip("mutability") unless subject.mutable?
108+
subject.delete(*@statements)
109+
expect(subject.find { |s| subject.has_statement?(s) }).to be_nil
117110
end
118111

119112
it "should support wildcard deletions" do
120-
pending("mutability", :unless => subject.mutable?) do
121-
# nothing deleted
122-
require 'digest/sha1'
123-
count = subject.count
124-
subject.delete([nil, nil, random = Digest::SHA1.hexdigest(File.read(__FILE__))])
125-
expect(subject).not_to be_empty
126-
expect(subject.count).to eq count
127-
128-
# everything deleted
129-
subject.delete([nil, nil, nil])
130-
expect(subject).to be_empty
131-
end
113+
skip("mutability") unless subject.mutable?
114+
# nothing deleted
115+
require 'digest/sha1'
116+
count = subject.count
117+
subject.delete([nil, nil, Digest::SHA1.hexdigest(File.read(__FILE__))])
118+
expect(subject).not_to be_empty
119+
expect(subject.count).to eq count
120+
121+
# everything deleted
122+
subject.delete([nil, nil, nil])
123+
expect(subject).to be_empty
132124
end
133125

134126
it "should only delete statements when the context matches" do
135-
pending("mutability", :unless => subject.mutable?) do
136-
# Setup three statements identical except for context
137-
count = subject.count + (@supports_context ? 3 : 1)
138-
s1 = RDF::Statement.new(resource, RDF::URI.new("urn:predicate:1"), RDF::URI.new("urn:object:1"))
139-
s2 = s1.dup
140-
s2.context = RDF::URI.new("urn:context:1")
141-
s3 = s1.dup
142-
s3.context = RDF::URI.new("urn:context:2")
143-
subject.insert(s1)
144-
subject.insert(s2)
145-
subject.insert(s3)
146-
expect(subject.count).to eq count
147-
148-
# Delete one by one
149-
subject.delete(s1)
150-
expect(subject.count).to eq count - (@supports_context ? 1 : 1)
151-
subject.delete(s2)
152-
expect(subject.count).to eq count - (@supports_context ? 2 : 1)
153-
subject.delete(s3)
154-
expect(subject.count).to eq count - (@supports_context ? 3 : 1)
155-
end
127+
skip("mutability") unless subject.mutable?
128+
# Setup three statements identical except for context
129+
count = subject.count + (@supports_context ? 3 : 1)
130+
s1 = RDF::Statement.new(resource, RDF::URI.new("urn:predicate:1"), RDF::URI.new("urn:object:1"))
131+
s2 = s1.dup
132+
s2.context = RDF::URI.new("urn:context:1")
133+
s3 = s1.dup
134+
s3.context = RDF::URI.new("urn:context:2")
135+
subject.insert(s1)
136+
subject.insert(s2)
137+
subject.insert(s3)
138+
expect(subject.count).to eq count
139+
140+
# Delete one by one
141+
subject.delete(s1)
142+
expect(subject.count).to eq count - (@supports_context ? 1 : 1)
143+
subject.delete(s2)
144+
expect(subject.count).to eq count - (@supports_context ? 2 : 1)
145+
subject.delete(s3)
146+
expect(subject.count).to eq count - (@supports_context ? 3 : 1)
156147
end
157148
end
158149
end

lib/rdf/spec/queryable.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,11 @@ module RDF_Queryable
188188
its(:count) {should == 2}
189189

190190
it "has two solutions" do
191-
expect(subject.any? {|s| s.subject == RDF::URI("http://example.org/xi1")}).to be_true
191+
expect(subject.any? {|s| s.subject == RDF::URI("http://example.org/xi1")}).to be_truthy
192192
end
193193

194194
it "has xi2 as a solution" do
195-
expect(subject.any? {|s| s.subject == RDF::URI("http://example.org/xi2")}).to be_true
195+
expect(subject.any? {|s| s.subject == RDF::URI("http://example.org/xi2")}).to be_truthy
196196
end
197197
end
198198

@@ -201,7 +201,7 @@ module RDF_Queryable
201201
its(:count) {should == 1}
202202

203203
it "has xd1 as a solution" do
204-
expect(subject.any? {|s| s.subject == RDF::URI("http://example.org/xd1")}).to be_true
204+
expect(subject.any? {|s| s.subject == RDF::URI("http://example.org/xd1")}).to be_truthy
205205
end
206206
end
207207
end
@@ -213,7 +213,7 @@ module RDF_Queryable
213213
# @see RDF::Queryable#query_execute
214214
describe "#query_execute" do
215215
it "defines a protected #query_execute method" do
216-
expect(subject.class.protected_method_defined?(:query_execute)).to be_true
216+
expect(subject.class.protected_method_defined?(:query_execute)).to be_truthy
217217
end
218218

219219
context "when called" do
@@ -237,7 +237,7 @@ module RDF_Queryable
237237
# @see RDF::Queryable#query_pattern
238238
describe "#query_pattern" do
239239
it "defines a protected #query_pattern method" do
240-
expect(subject.class.protected_method_defined?(:query_pattern)).to be_true
240+
expect(subject.class.protected_method_defined?(:query_pattern)).to be_truthy
241241
end
242242

243243
context "when called" do

lib/rdf/spec/reader.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module RDF_Reader
2222

2323
describe ".open" do
2424
before(:each) do
25-
RDF::Util::File.stub(:open_file).and_yield(StringIO.new(@reader_input))
25+
allow(RDF::Util::File).to receive(:open_file).and_yield(StringIO.new(@reader_input))
2626
end
2727

2828
it "yields reader given file_name" do

lib/rdf/spec/writable.rb

Lines changed: 58 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -23,115 +23,102 @@ module RDF_Writable
2323

2424
describe "#<<" do
2525
it "inserts a reader" do
26-
pending("writability", :unless => subject.writable?) do
27-
reader = RDF::NTriples::Reader.new(File.open(@filename)).to_a
28-
subject << reader
29-
expect(subject).to have_statement(statement)
30-
expect(subject.count).to eq count
31-
end
26+
skip("writability") unless subject.writable?
27+
reader = RDF::NTriples::Reader.new(File.open(@filename)).to_a
28+
subject << reader
29+
expect(subject).to have_statement(statement)
30+
expect(subject.count).to eq count
3231
end
3332

3433
it "inserts a graph" do
35-
pending("writability", :unless => subject.writable?) do
36-
graph = RDF::Graph.new << @statements
37-
subject << graph
38-
expect(subject).to have_statement(statement)
39-
expect(subject.count).to eq count
40-
end
34+
skip("writability") unless subject.writable?
35+
graph = RDF::Graph.new << @statements
36+
subject << graph
37+
expect(subject).to have_statement(statement)
38+
expect(subject.count).to eq count
4139
end
4240

4341
it "inserts an enumerable" do
44-
pending("writability", :unless => subject.writable?) do
45-
enumerable = @statements.dup.extend(RDF::Enumerable)
46-
subject << enumerable
47-
expect(subject).to have_statement(statement)
48-
expect(subject.count).to eq count
49-
end
42+
skip("writability") unless subject.writable?
43+
enumerable = @statements.dup.extend(RDF::Enumerable)
44+
subject << enumerable
45+
expect(subject).to have_statement(statement)
46+
expect(subject.count).to eq count
5047
end
5148

5249
it "inserts data responding to #to_rdf" do
53-
pending("writability", :unless => subject.writable?) do
54-
mock = double('mock')
55-
mock.stub(:to_rdf).and_return(@statements)
56-
subject << mock
57-
expect(subject).to have_statement(statement)
58-
expect(subject.count).to eq count
59-
end
50+
skip("writability") unless subject.writable?
51+
mock = double('mock')
52+
allow(mock).to receive(:to_rdf).and_return(@statements)
53+
subject << mock
54+
expect(subject).to have_statement(statement)
55+
expect(subject.count).to eq count
6056
end
6157

6258
it "inserts a statement" do
63-
pending("writability", :unless => subject.writable?) do
64-
subject << statement
65-
expect(subject).to have_statement(statement)
66-
expect(subject.count).to eq 1
67-
end
59+
skip("writability") unless subject.writable?
60+
subject << statement
61+
expect(subject).to have_statement(statement)
62+
expect(subject.count).to eq 1
6863
end
6964

7065
it "inserts an invalid statement" do
71-
pending("writability", :unless => subject.writable?) do
72-
s = RDF::Statement.from([nil, nil, nil])
73-
expect(s).not_to be_valid
74-
subject << s
75-
expect(subject.count).to eq 1
76-
end
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
7771
end
7872
end
7973

8074
context "when inserting statements" do
8175
it "should support #insert" do
82-
pending("writability", :unless => subject.writable?) do
83-
expect(subject).to respond_to(:insert)
84-
end
76+
skip("writability") unless subject.writable?
77+
expect(subject).to respond_to(:insert)
8578
end
8679

8780
it "should not raise errors" do
88-
pending("writability", :unless => subject.writable?) do
89-
expect { subject.insert(statement) }.not_to raise_error
90-
end
81+
skip("writability") unless subject.writable?
82+
expect { subject.insert(statement) }.not_to raise_error
9183
end
9284

9385
it "should support inserting one statement at a time" do
94-
pending("writability", :unless => subject.writable?) do
95-
subject.insert(statement)
96-
expect(subject).to have_statement(statement)
97-
end
86+
skip("writability") unless subject.writable?
87+
subject.insert(statement)
88+
expect(subject).to have_statement(statement)
9889
end
9990

10091
it "should support inserting multiple statements at a time" do
101-
pending("writability", :unless => subject.writable?) do
102-
subject.insert(*@statements)
103-
end
92+
skip("writability") unless subject.writable?
93+
subject.insert(*@statements)
10494
end
10595

10696
it "should insert statements successfully" do
107-
pending("writability", :unless => subject.writable?) do
108-
subject.insert(*@statements)
109-
expect(subject.count).to eq count
110-
end
97+
skip("writability") unless subject.writable?
98+
subject.insert(*@statements)
99+
expect(subject.count).to eq count
111100
end
112101

113102
it "should not insert a statement twice" do
114-
pending("writability", :unless => subject.writable?) do
115-
subject.insert(statement)
116-
subject.insert(statement)
117-
expect(subject.count).to eq 1
118-
end
103+
skip("writability") unless subject.writable?
104+
subject.insert(statement)
105+
subject.insert(statement)
106+
expect(subject.count).to eq 1
119107
end
120108

121109
it "should treat statements with a different context as distinct" do
122-
pending("writability", :unless => subject.writable?) do
123-
s1 = statement.dup
124-
s1.context = nil
125-
s2 = statement.dup
126-
s2.context = RDF::URI.new("urn:context:1")
127-
s3 = statement.dup
128-
s3.context = RDF::URI.new("urn:context:2")
129-
subject.insert(s1)
130-
subject.insert(s2)
131-
subject.insert(s3)
132-
# If contexts are not suported, all three are redundant
133-
expect(subject.count).to eq (@supports_context ? 3 : 1)
134-
end
110+
skip("writability") unless subject.writable?
111+
s1 = statement.dup
112+
s1.context = nil
113+
s2 = statement.dup
114+
s2.context = RDF::URI.new("urn:context:1")
115+
s3 = statement.dup
116+
s3.context = RDF::URI.new("urn:context:2")
117+
subject.insert(s1)
118+
subject.insert(s2)
119+
subject.insert(s3)
120+
# If contexts are not suported, all three are redundant
121+
expect(subject.count).to eq (@supports_context ? 3 : 1)
135122
end
136123
end
137124
end

lib/rdf/spec/writer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module RDF_Writer
3131

3232
describe ".open" do
3333
before(:each) do
34-
RDF::Util::File.stub(:open_file).and_yield(StringIO.new("foo"))
34+
allow(RDF::Util::File).to receive(:open_file).and_yield(StringIO.new("foo"))
3535
@dir = Dir.mktmpdir
3636
@basename = File.join(@dir, "foo")
3737
end

0 commit comments

Comments
 (0)