Skip to content

Commit 783d563

Browse files
committed
Update to use expect syntax.
1 parent 4db71b1 commit 783d563

12 files changed

Lines changed: 276 additions & 274 deletions

File tree

lib/rdf/spec/countable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module RDF_Countable
3838
its(:to_enum) {should be_countable}
3939
its(:enum_for) {should be_countable}
4040
it "#enum_for(:each)" do
41-
subject.enum_for(:each).should be_countable
41+
expect(subject.enum_for(:each)).to be_countable
4242
end
4343
end
4444
end

lib/rdf/spec/durable.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ module RDF_Durable
2929
subject {@load_durable.call}
3030
it {should respond_to(:durable?)}
3131
it "should support #durable?" do
32-
[true,false].member?(subject.durable?).should be_true
32+
expect([true,false]).to be_member(subject.durable?)
3333
end
3434

3535
it {should respond_to(:nondurable?)}
3636
it "should support #nondurable?" do
37-
[true,false].member?(@load_durable.call.nondurable?).should be_true
37+
expect([true,false]).to be_member(@load_durable.call.nondurable?)
3838
end
3939
its(:nondurable?) {should_not == subject.durable?}
4040

4141
it "should save contents between instantiations" do
4242
if subject.durable?
4343
subject.load(RDF::Spec::TRIPLES_FILE)
44-
subject.count.should == File.readlines(RDF::Spec::TRIPLES_FILE).size
44+
expect(subject.count).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
4545
end
4646
end
4747
end

lib/rdf/spec/enumerable.rb

Lines changed: 65 additions & 65 deletions
Large diffs are not rendered by default.

lib/rdf/spec/format.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ module RDF_Format
1313
describe ".for" do
1414
RDF::Format.file_extensions.each do |ext, formats|
1515
it "detects #{formats.first} using file path foo.#{ext}" do
16-
RDF::Format.for("foo.#{ext}").should == formats.first
16+
expect(RDF::Format.for("foo.#{ext}")).to eq formats.first
1717
end
1818

1919
it "detects #{formats.first} using file_name foo.#{ext}" do
20-
RDF::Format.for(:file_name => "foo.#{ext}").should == formats.first
20+
expect(RDF::Format.for(:file_name => "foo.#{ext}")).to eq formats.first
2121
end
2222

2323
it "detects #{formats.first} using file_extension #{ext}" do
24-
RDF::Format.for(:file_extension => ext).should == formats.first
24+
expect(RDF::Format.for(:file_extension => ext)).to eq formats.first
2525
end
2626
end
2727

2828
RDF::Format.content_types.each do |content_type, formats|
2929
it "detects #{formats.first} using content_type #{content_type}" do
30-
RDF::Format.for(:content_type => content_type).should == formats.first
30+
expect(RDF::Format.for(:content_type => content_type)).to eq formats.first
3131
end
3232
end
3333
end
3434

3535
describe ".reader" do
3636
it "returns a reader" do
3737
subject.each do |f|
38-
f.reader.should_not be_nil
38+
expect(f.reader).not_to be_nil
3939
end
4040
end
4141
end
@@ -46,7 +46,7 @@ module RDF_Format
4646
it "returns a writer" do
4747
subject.each do |f|
4848
format_namespace = f.name.split('::')[0..-2].inject(Kernel) {|base, const| base.const_get(const)}
49-
f.writer.should_not be_nil if format_namespace.const_defined?(:Writer)
49+
expect(f.writer).not_to be_nil if format_namespace.const_defined?(:Writer)
5050
end
5151
end
5252
end

lib/rdf/spec/matchers.rb

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,127 +8,127 @@ module RDF; module Spec
88
module Matchers
99
RSpec::Matchers.define :be_countable do
1010
match do |countable|
11-
countable.should be_a_kind_of(RDF::Countable)
11+
expect(countable).to be_a_kind_of(RDF::Countable)
1212
true
1313
end
1414
end
1515

1616
RSpec::Matchers.define :be_enumerable do
1717
match do |enumerable|
18-
enumerable.should be_a_kind_of(RDF::Enumerable)
18+
expect(enumerable).to be_a_kind_of(RDF::Enumerable)
1919
true
2020
end
2121
end
2222

2323
RSpec::Matchers.define :be_an_enumerator do
2424
match do |enumerator|
25-
enumerator.should be_a_kind_of(RDF::Enumerator)
25+
expect(enumerator).to be_a_kind_of(RDF::Enumerator)
2626
true
2727
end
2828
end
2929

3030
RSpec::Matchers.define :be_queryable do
3131
match do |enumerable|
32-
enumerable.should be_a_kind_of(RDF::Queryable)
32+
expect(enumerable).to be_a_kind_of(RDF::Queryable)
3333
true
3434
end
3535
end
3636

3737
RSpec::Matchers.define :be_mutable do
3838
match do |enumerable|
39-
enumerable.should be_a_kind_of(RDF::Mutable)
39+
expect(enumerable).to be_a_kind_of(RDF::Mutable)
4040
true
4141
end
4242
end
4343

4444
RSpec::Matchers.define :be_a_statement do
4545
match do |statement|
46-
statement.should be_instance_of(RDF::Statement)
47-
statement.subject.should be_a_kind_of(RDF::Resource)
48-
statement.predicate.should be_a_kind_of(RDF::URI)
49-
statement.object.should be_a_kind_of(RDF::Value)
46+
expect(statement).to be_instance_of(RDF::Statement)
47+
expect(statement.subject).to be_a_kind_of(RDF::Resource)
48+
expect(statement.predicate).to be_a_kind_of(RDF::URI)
49+
expect(statement.object).to be_a_kind_of(RDF::Value)
5050
true
5151
end
5252
end
5353

5454
RSpec::Matchers.define :be_a_triple do
5555
match do |triple|
56-
triple.should be_instance_of(Array)
57-
triple.size.should == 3
58-
triple[0].should be_a_kind_of(RDF::Resource)
59-
triple[1].should be_a_kind_of(RDF::URI)
60-
triple[2].should be_a_kind_of(RDF::Value)
56+
expect(triple).to be_instance_of(Array)
57+
expect(triple.size).to eq 3
58+
expect(triple[0]).to be_a_kind_of(RDF::Resource)
59+
expect(triple[1]).to be_a_kind_of(RDF::URI)
60+
expect(triple[2]).to be_a_kind_of(RDF::Value)
6161
true
6262
end
6363
end
6464

6565
RSpec::Matchers.define :be_a_quad do
6666
match do |quad|
67-
quad.should be_instance_of(Array)
68-
quad.size.should == 4
69-
quad[0].should be_a_kind_of(RDF::Resource)
70-
quad[1].should be_a_kind_of(RDF::URI)
71-
quad[2].should be_a_kind_of(RDF::Value)
72-
quad[3].should be_a_kind_of(RDF::Resource) unless quad[3].nil?
67+
expect(quad).to be_instance_of(Array)
68+
expect(quad.size).to eq 4
69+
expect(quad[0]).to be_a_kind_of(RDF::Resource)
70+
expect(quad[1]).to be_a_kind_of(RDF::URI)
71+
expect(quad[2]).to be_a_kind_of(RDF::Value)
72+
expect(quad[3]).to be_a_kind_of(RDF::Resource) unless quad[3].nil?
7373
true
7474
end
7575
end
7676

7777
RSpec::Matchers.define :be_a_resource do
7878
match do |value|
79-
value.should be_a_kind_of(RDF::Resource)
79+
expect(value).to be_a_kind_of(RDF::Resource)
8080
true
8181
end
8282
end
8383

8484
RSpec::Matchers.define :be_a_node do
8585
match do |value|
86-
value.should be_a_kind_of(RDF::Node)
86+
expect(value).to be_a_kind_of(RDF::Node)
8787
true
8888
end
8989
end
9090

9191
RSpec::Matchers.define :be_a_uri do
9292
match do |value|
93-
value.should be_a_kind_of(RDF::URI)
93+
expect(value).to be_a_kind_of(RDF::URI)
9494
true
9595
end
9696
end
9797

9898
RSpec::Matchers.define :be_a_value do
9999
match do |value|
100-
value.should be_a_kind_of(RDF::Value)
100+
expect(value).to be_a_kind_of(RDF::Value)
101101
true
102102
end
103103
end
104104

105105
RSpec::Matchers.define :be_a_list do
106106
match do |value|
107-
value.should be_an(RDF::List)
107+
expect(value).to be_an(RDF::List)
108108
true
109109
end
110110
end
111111

112112
RSpec::Matchers.define :be_a_vocabulary do |base_uri|
113113
match do |vocabulary|
114-
vocabulary.should be_a_kind_of(Module)
115-
vocabulary.should respond_to(:to_uri)
116-
vocabulary.to_uri.to_s.should == base_uri
117-
vocabulary.should respond_to(:[])
114+
expect(vocabulary).to be_a_kind_of(Module)
115+
expect(vocabulary).to respond_to(:to_uri)
116+
expect(vocabulary.to_uri.to_s).to eq base_uri
117+
expect(vocabulary).to respond_to(:[])
118118
true
119119
end
120120
end
121121

122122
RSpec::Matchers.define :have_properties do |base_uri, properties|
123123
match do |vocabulary|
124124
properties.map { |p| p.to_sym }.each do |property|
125-
vocabulary[property].should be_a_uri
126-
vocabulary[property].to_s.should == "#{base_uri}#{property}"
127-
vocabulary.should respond_to(property)
125+
expect(vocabulary[property]).to be_a_uri
126+
expect(vocabulary[property].to_s).to eq "#{base_uri}#{property}"
127+
expect(vocabulary).to respond_to(property)
128128
expect { vocabulary.send(property) }.not_to raise_error
129-
vocabulary.send(property).should be_a_uri
130-
vocabulary.send(property.to_s).should be_a_uri
131-
vocabulary.send(property).to_s.should == "#{base_uri}#{property}"
129+
expect(vocabulary.send(property)).to be_a_uri
130+
expect(vocabulary.send(property.to_s)).to be_a_uri
131+
expect(vocabulary.send(property).to_s).to eq "#{base_uri}#{property}"
132132
end
133133
true
134134
end
@@ -145,14 +145,14 @@ module Matchers
145145

146146
RSpec::Matchers.define :be_a_repository do
147147
match do |repository|
148-
repository.should be_a_kind_of(RDF::Repository)
148+
expect(repository).to be_a_kind_of(RDF::Repository)
149149
true
150150
end
151151
end
152152

153153
RSpec::Matchers.define :be_a_repository_of_size do |size|
154154
match do |repository|
155-
repository.should be_a_repository
155+
expect(repository).to be_a_repository
156156
repository.size == size
157157
end
158158
end

lib/rdf/spec/mutable.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,25 @@ module RDF_Mutable
6767
it "should load statements" do
6868
pending("mutability", :unless => subject.mutable?) do
6969
subject.load RDF::Spec::TRIPLES_FILE
70-
subject.size.should == File.readlines(RDF::Spec::TRIPLES_FILE).size
71-
subject.should have_subject(resource)
70+
expect(subject.size).to eq File.readlines(RDF::Spec::TRIPLES_FILE).size
71+
expect(subject).to have_subject(resource)
7272
end
7373
end
7474

7575
it "should load statements with a context override" do
7676
pending("mutability and contextuality", :unless => (subject.mutable? && @supports_context)) do
7777
subject.load RDF::Spec::TRIPLES_FILE, :context => context
78-
subject.should have_context(context)
79-
subject.query(:context => context).size.should == subject.size
78+
expect(subject).to have_context(context)
79+
expect(subject.query(:context => context).size).to eq subject.size
8080
end
8181
end
8282
end
8383

8484
context "#from_{reader}" do
8585
it "should instantiate a reader" do
8686
reader = double("reader")
87-
reader.should_receive(:new).and_return(RDF::NTriples::Reader.new(""))
88-
RDF::Reader.should_receive(:for).with(:a_reader).and_return(reader)
87+
expect(reader).to receive(:new).and_return(RDF::NTriples::Reader.new(""))
88+
expect(RDF::Reader).to receive(:for).with(:a_reader).and_return(reader)
8989
subject.send(:from_a_reader)
9090
end
9191
end
@@ -105,14 +105,14 @@ module RDF_Mutable
105105
it "should support deleting one statement at a time" do
106106
pending("mutability", :unless => subject.mutable?) do
107107
subject.delete(@statements.first)
108-
subject.should_not have_statement(@statements.first)
108+
expect(subject).not_to have_statement(@statements.first)
109109
end
110110
end
111111

112112
it "should support deleting multiple statements at a time" do
113113
pending("mutability", :unless => subject.mutable?) do
114114
subject.delete(*@statements)
115-
subject.find { |s| subject.has_statement?(s) }.should be_false
115+
expect(subject.find { |s| subject.has_statement?(s) }).to be_false
116116
end
117117
end
118118

@@ -122,12 +122,12 @@ module RDF_Mutable
122122
require 'digest/sha1'
123123
count = subject.count
124124
subject.delete([nil, nil, random = Digest::SHA1.hexdigest(File.read(__FILE__))])
125-
subject.should_not be_empty
126-
subject.count.should == count
125+
expect(subject).not_to be_empty
126+
expect(subject.count).to eq count
127127

128128
# everything deleted
129129
subject.delete([nil, nil, nil])
130-
subject.should be_empty
130+
expect(subject).to be_empty
131131
end
132132
end
133133

@@ -143,15 +143,15 @@ module RDF_Mutable
143143
subject.insert(s1)
144144
subject.insert(s2)
145145
subject.insert(s3)
146-
subject.count.should == count
146+
expect(subject.count).to eq count
147147

148148
# Delete one by one
149149
subject.delete(s1)
150-
subject.count.should == count - (@supports_context ? 1 : 1)
150+
expect(subject.count).to eq count - (@supports_context ? 1 : 1)
151151
subject.delete(s2)
152-
subject.count.should == count - (@supports_context ? 2 : 1)
152+
expect(subject.count).to eq count - (@supports_context ? 2 : 1)
153153
subject.delete(s3)
154-
subject.count.should == count - (@supports_context ? 3 : 1)
154+
expect(subject.count).to eq count - (@supports_context ? 3 : 1)
155155
end
156156
end
157157
end

0 commit comments

Comments
 (0)