Skip to content

Commit 9d48688

Browse files
committed
Update lambda {}.should raise_error to expect {}.to raise_error
Also should_not => not_to Also not_to raise_error(Specific) => not_to raise_error
1 parent 3b3120c commit 9d48688

8 files changed

Lines changed: 43 additions & 43 deletions

File tree

lib/rdf/spec/enumerable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ module RDF_Enumerable
420420
end
421421

422422
it "raises error on unknown format" do
423-
lambda {subject.dump(:foobar)}.should raise_error(RDF::WriterError, /No writer found/)
423+
expect {subject.dump(:foobar)}.to raise_error(RDF::WriterError, /No writer found/)
424424
end
425425
end
426426
end

lib/rdf/spec/indexable.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ module RDF_Indexable
1515
it {should respond_to(:index!)}
1616

1717
it "does not raise error on #index! if #indexed?" do
18-
lambda {subject.index!}.should_not raise_error if subject.indexed?
18+
expect {subject.index!}.not_to raise_error if subject.indexed?
1919
end
2020

2121
it "raises error on #index! if not #indexed?" do
22-
lambda {subject.index!}.should raise_error unless subject.indexed?
22+
expect {subject.index!}.to raise_error unless subject.indexed?
2323
end
2424
end
2525
end

lib/rdf/spec/matchers.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ module Matchers
125125
vocabulary[property].should be_a_uri
126126
vocabulary[property].to_s.should == "#{base_uri}#{property}"
127127
vocabulary.should respond_to(property)
128-
lambda { vocabulary.send(property) }.should_not raise_error
128+
expect { vocabulary.send(property) }.not_to raise_error
129129
vocabulary.send(property).should be_a_uri
130130
vocabulary.send(property.to_s).should be_a_uri
131131
vocabulary.send(property).to_s.should == "#{base_uri}#{property}"

lib/rdf/spec/mutable.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,18 @@ module RDF_Mutable
4949

5050
context "#load" do
5151
it "should require an argument" do
52-
lambda { subject.load }.should raise_error(ArgumentError)
52+
expect { subject.load }.to raise_error(ArgumentError)
5353
end
5454

5555
it "should accept a string filename argument" do
5656
pending("mutability", :unless => subject.mutable?) do
57-
lambda { subject.load(RDF::Spec::TRIPLES_FILE) }.should_not raise_error(ArgumentError)
57+
expect { subject.load(RDF::Spec::TRIPLES_FILE) }.not_to raise_error
5858
end
5959
end
6060

6161
it "should accept an optional hash argument" do
6262
pending("mutability", :unless => subject.mutable?) do
63-
lambda { subject.load(RDF::Spec::TRIPLES_FILE, {}) }.should_not raise_error(ArgumentError)
63+
expect { subject.load(RDF::Spec::TRIPLES_FILE, {}) }.not_to raise_error
6464
end
6565
end
6666

@@ -83,7 +83,7 @@ module RDF_Mutable
8383

8484
context "#from_{reader}" do
8585
it "should instantiate a reader" do
86-
reader = mock("reader")
86+
reader = double("reader")
8787
reader.should_receive(:new).and_return(RDF::NTriples::Reader.new(""))
8888
RDF::Reader.should_receive(:for).with(:a_reader).and_return(reader)
8989
subject.send(:from_a_reader)
@@ -98,7 +98,7 @@ module RDF_Mutable
9898

9999
it "should not raise errors" do
100100
pending("mutability", :unless => subject.mutable?) do
101-
lambda { subject.delete(@statements.first) }.should_not raise_error
101+
expect { subject.delete(@statements.first) }.not_to raise_error
102102
end
103103
end
104104

lib/rdf/spec/queryable.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,28 @@ module RDF_Queryable
3030

3131
context "when called" do
3232
it "requires an argument" do
33-
lambda { subject.query }.should raise_error(ArgumentError)
33+
expect { subject.query }.to raise_error(ArgumentError)
3434
end
3535

3636
it "accepts a pattern argument" do
37-
lambda { subject.query(RDF::Query::Pattern.new(nil, nil, nil)) }.should_not raise_error(ArgumentError)
38-
lambda { subject.query(RDF::Query::Pattern.new(:s, :p, :o)) }.should_not raise_error(ArgumentError)
37+
expect { subject.query(RDF::Query::Pattern.new(nil, nil, nil)) }.not_to raise_error
38+
expect { subject.query(RDF::Query::Pattern.new(:s, :p, :o)) }.not_to raise_error
3939
end
4040

4141
it "accepts a statement argument" do
42-
lambda { subject.query(RDF::Statement.new(nil, nil, nil)) }.should_not raise_error(ArgumentError)
42+
expect { subject.query(RDF::Statement.new(nil, nil, nil)) }.not_to raise_error
4343
end
4444

4545
it "accepts a triple argument" do
46-
lambda { subject.query([nil, nil, nil]) }.should_not raise_error(ArgumentError)
46+
expect { subject.query([nil, nil, nil]) }.not_to raise_error
4747
end
4848

4949
it "accepts a quad argument" do
50-
lambda { subject.query([nil, nil, nil, nil]) }.should_not raise_error(ArgumentError)
50+
expect { subject.query([nil, nil, nil, nil]) }.not_to raise_error
5151
end
5252

5353
it "accepts a hash argument" do
54-
lambda { subject.query({}) }.should_not raise_error(ArgumentError)
54+
expect { subject.query({}) }.not_to raise_error
5555
end
5656

5757
it "does not alter a given hash argument" do
@@ -62,7 +62,7 @@ module RDF_Queryable
6262
end
6363

6464
it "rejects other kinds of arguments" do
65-
lambda { subject.query(nil) }.should raise_error(ArgumentError)
65+
expect { subject.query(nil) }.to raise_error(ArgumentError)
6666
end
6767

6868
context "with a block" do
@@ -158,7 +158,7 @@ module RDF_Queryable
158158

159159
context "when called" do
160160
it "requires an argument" do
161-
lambda { subject.send(:query_pattern) }.should raise_error(ArgumentError)
161+
expect { subject.send(:query_pattern) }.to raise_error(ArgumentError)
162162
end
163163

164164
it "yields to the given block" do
@@ -243,7 +243,7 @@ module RDF_Queryable
243243
end
244244

245245
it "returns enumerator without a pattern" do
246-
lambda { subject.first }.should_not raise_error(ArgumentError)
246+
expect { subject.first }.not_to raise_error
247247
subject.first.should == subject.each.first # uses an Enumerator
248248
end
249249

@@ -275,7 +275,7 @@ module RDF_Queryable
275275
end
276276

277277
it "returns enumerator without a pattern", :pending => (defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java') do
278-
lambda { subject.first_subject }.should_not raise_error(ArgumentError)
278+
expect { subject.first_subject }.not_to raise_error
279279
subject.first_subject.should == subject.first.subject
280280
end
281281

@@ -306,7 +306,7 @@ module RDF_Queryable
306306
it {should respond_to(:first_predicate)}
307307

308308
it "returns enumerator without a pattern", :pending => (defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java') do
309-
lambda { subject.first_predicate }.should_not raise_error(ArgumentError)
309+
expect { subject.first_predicate }.not_to raise_error
310310
subject.first_predicate.should == subject.first.predicate
311311
end
312312

@@ -336,7 +336,7 @@ module RDF_Queryable
336336
it {should respond_to(:first_object)}
337337

338338
it "returns enurator without a pattern", :pending => (defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java') do
339-
lambda { subject.first_object }.should_not raise_error(ArgumentError)
339+
expect { subject.first_object }.not_to raise_error
340340
subject.first_object.should == subject.first.object
341341
end
342342

@@ -374,7 +374,7 @@ module RDF_Queryable
374374
it {should respond_to(:first_literal)}
375375

376376
it "returns a literal without a pattern" do
377-
lambda { subject.first_literal }.should_not raise_error(ArgumentError)
377+
expect { subject.first_literal }.not_to raise_error
378378
subject.first_literal.should == literal
379379
end
380380

@@ -404,7 +404,7 @@ module RDF_Queryable
404404
it {should respond_to(:first_value)}
405405

406406
it "returns first literal without a pattern" do
407-
lambda { subject.first_value }.should_not raise_error(ArgumentError)
407+
expect { subject.first_value }.not_to raise_error
408408
subject.first_value.should == subject.first_literal.value
409409
end
410410

lib/rdf/spec/reader.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module RDF_Reader
2727
@reader_class.format.each do |f|
2828
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
2929
f.file_extensions.each_pair do |sym, content_type|
30-
reader_mock = mock("reader")
30+
reader_mock = double("reader")
3131
reader_mock.should_receive(:got_here)
3232
@reader_class.should_receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
3333
@reader_class.open("foo.#{sym}") do |r|
@@ -42,7 +42,7 @@ module RDF_Reader
4242
@reader_class.format.each do |f|
4343
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
4444
sym = f.to_sym # Like RDF::NTriples::Format => :ntriples
45-
reader_mock = mock("reader")
45+
reader_mock = double("reader")
4646
reader_mock.should_receive(:got_here)
4747
@reader_class.should_receive(:for).with(sym).and_return(@reader_class)
4848
@reader_class.open("foo.#{sym}", :format => sym) do |r|
@@ -56,7 +56,7 @@ module RDF_Reader
5656
@reader_class.format.each do |f|
5757
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
5858
f.file_extensions.each_pair do |sym, content_type|
59-
reader_mock = mock("reader")
59+
reader_mock = double("reader")
6060
reader_mock.should_receive(:got_here)
6161
@reader_class.should_receive(:for).with(:file_name => "foo.#{sym}").and_return(@reader_class)
6262
@reader_class.open("foo.#{sym}", :file_name => "foo.#{sym}") do |r|
@@ -71,7 +71,7 @@ module RDF_Reader
7171
@reader_class.format.each do |f|
7272
RDF::Util::File.stub!(:open_file).and_yield(StringIO.new("foo"))
7373
f.content_types.each_pair do |content_type, formats|
74-
reader_mock = mock("reader")
74+
reader_mock = double("reader")
7575
reader_mock.should_receive(:got_here)
7676
@reader_class.should_receive(:for).with(:content_type => content_type, :file_name => "foo").and_return(@reader_class)
7777
@reader_class.open("foo", :content_type => content_type) do |r|
@@ -92,7 +92,7 @@ module RDF_Reader
9292

9393
describe ".new" do
9494
it "sets @input to StringIO given a string" do
95-
reader_mock = mock("reader")
95+
reader_mock = double("reader")
9696
reader_mock.should_receive(:got_here)
9797
@reader_class.new("string") do |r|
9898
reader_mock.got_here
@@ -101,7 +101,7 @@ module RDF_Reader
101101
end
102102

103103
it "sets @input to input given something other than a string" do
104-
reader_mock = mock("reader")
104+
reader_mock = double("reader")
105105
reader_mock.should_receive(:got_here)
106106
file = StringIO.new("")
107107
@reader_class.new(file) do |r|
@@ -122,7 +122,7 @@ module RDF_Reader
122122
end
123123

124124
it "sets canonicalize given :canonicalize => true" do
125-
reader_mock = mock("reader")
125+
reader_mock = double("reader")
126126
reader_mock.should_receive(:got_here)
127127
@reader_class.new("string", :canonicalize => true) do |r|
128128
reader_mock.got_here
@@ -131,7 +131,7 @@ module RDF_Reader
131131
end
132132

133133
it "sets intern given :intern => true" do
134-
reader_mock = mock("reader")
134+
reader_mock = double("reader")
135135
reader_mock.should_receive(:got_here)
136136
@reader_class.new("string", :intern => true) do |r|
137137
reader_mock.got_here
@@ -140,7 +140,7 @@ module RDF_Reader
140140
end
141141

142142
it "sets prefixes given :prefixes => {}" do
143-
reader_mock = mock("reader")
143+
reader_mock = double("reader")
144144
reader_mock.should_receive(:got_here)
145145
@reader_class.new("string", :prefixes => {:a => "b"}) do |r|
146146
reader_mock.got_here

lib/rdf/spec/writable.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module RDF_Writable
8686

8787
it "should not raise errors" do
8888
pending("writability", :unless => subject.writable?) do
89-
lambda { subject.insert(statement) }.should_not raise_error
89+
expect { subject.insert(statement) }.not_to raise_error
9090
end
9191
end
9292

lib/rdf/spec/writer.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ module RDF_Writer
4343
it "yields writer given file_name" do
4444
@writer_class.format.each do |f|
4545
f.file_extensions.each_pair do |sym, content_type|
46-
writer_mock = mock("writer")
46+
writer_mock = double("writer")
4747
writer_mock.should_receive(:got_here)
4848
@writer_class.should_receive(:for).with(:file_name => "#{@basename}.#{sym}").and_return(@writer_class)
4949
@writer_class.open("#{@basename}.#{sym}") do |r|
@@ -57,7 +57,7 @@ module RDF_Writer
5757
it "yields writer given symbol" do
5858
@writer_class.format.each do |f|
5959
sym = f.to_sym # Like RDF::NTriples::Format => :ntriples
60-
writer_mock = mock("writer")
60+
writer_mock = double("writer")
6161
writer_mock.should_receive(:got_here)
6262
@writer_class.should_receive(:for).with(sym).and_return(@writer_class)
6363
@writer_class.open("#{@basename}.#{sym}", :format => sym) do |r|
@@ -70,7 +70,7 @@ module RDF_Writer
7070
it "yields writer given {:file_name => file_name}" do
7171
@writer_class.format.each do |f|
7272
f.file_extensions.each_pair do |sym, content_type|
73-
writer_mock = mock("writer")
73+
writer_mock = double("writer")
7474
writer_mock.should_receive(:got_here)
7575
@writer_class.should_receive(:for).with(:file_name => "#{@basename}.#{sym}").and_return(@writer_class)
7676
@writer_class.open("#{@basename}.#{sym}", :file_name => "#{@basename}.#{sym}") do |r|
@@ -84,7 +84,7 @@ module RDF_Writer
8484
it "yields writer given {:content_type => 'a/b'}" do
8585
@writer_class.format.each do |f|
8686
f.content_types.each_pair do |content_type, formats|
87-
writer_mock = mock("writer")
87+
writer_mock = double("writer")
8888
writer_mock.should_receive(:got_here)
8989
@writer_class.should_receive(:for).with(:content_type => content_type, :file_name => @basename).and_return(@writer_class)
9090
@writer_class.open(@basename, :content_type => content_type) do |r|
@@ -105,7 +105,7 @@ module RDF_Writer
105105

106106
describe ".new" do
107107
it "sets @output to $stdout by default" do
108-
writer_mock = mock("writer")
108+
writer_mock = double("writer")
109109
writer_mock.should_receive(:got_here)
110110
save, $stdout = $stdout, StringIO.new
111111

@@ -117,7 +117,7 @@ module RDF_Writer
117117
end
118118

119119
it "sets @output to file given something other than a string" do
120-
writer_mock = mock("writer")
120+
writer_mock = double("writer")
121121
writer_mock.should_receive(:got_here)
122122
file = StringIO.new
123123
file.should_receive(:write).any_number_of_times
@@ -128,7 +128,7 @@ module RDF_Writer
128128
end
129129

130130
it "sets prefixes given :prefixes => {}" do
131-
writer_mock = mock("writer")
131+
writer_mock = double("writer")
132132
writer_mock.should_receive(:got_here)
133133
@writer_class.new(StringIO.new, :prefixes => {:a => "b"}) do |r|
134134
writer_mock.got_here
@@ -137,7 +137,7 @@ module RDF_Writer
137137
end
138138

139139
#it "calls #write_prologue" do
140-
# writer_mock = mock("writer")
140+
# writer_mock = double("writer")
141141
# writer_mock.should_receive(:got_here)
142142
# @writer_class.any_instance.should_receive(:write_prologue)
143143
# @writer_class.new(StringIO.new) do |r|
@@ -146,7 +146,7 @@ module RDF_Writer
146146
#end
147147
#
148148
#it "calls #write_epilogue" do
149-
# writer_mock = mock("writer")
149+
# writer_mock = double("writer")
150150
# writer_mock.should_receive(:got_here)
151151
# @writer_class.any_instance.should_receive(:write_epilogue)
152152
# @writer_class.new(StringIO.new) do |r|

0 commit comments

Comments
 (0)