summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringio/reopen_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/stringio/reopen_spec.rb')
-rw-r--r--spec/ruby/library/stringio/reopen_spec.rb94
1 files changed, 47 insertions, 47 deletions
diff --git a/spec/ruby/library/stringio/reopen_spec.rb b/spec/ruby/library/stringio/reopen_spec.rb
index 151bb58c6f..3d4ae3a698 100644
--- a/spec/ruby/library/stringio/reopen_spec.rb
+++ b/spec/ruby/library/stringio/reopen_spec.rb
@@ -3,23 +3,23 @@ require_relative 'fixtures/classes'
describe "StringIO#reopen when passed [Object, Integer]" do
before :each do
- @io = StringIO.new(+"example")
+ @io = StringIO.new("example")
end
it "reopens self with the passed Object in the passed mode" do
- @io.reopen(+"reopened", IO::RDONLY)
- @io.closed_read?.should be_false
- @io.closed_write?.should be_true
+ @io.reopen("reopened", IO::RDONLY)
+ @io.closed_read?.should == false
+ @io.closed_write?.should == true
@io.string.should == "reopened"
@io.reopen(+"reopened, twice", IO::WRONLY)
- @io.closed_read?.should be_true
- @io.closed_write?.should be_false
+ @io.closed_read?.should == true
+ @io.closed_write?.should == false
@io.string.should == "reopened, twice"
@io.reopen(+"reopened, another time", IO::RDWR)
- @io.closed_read?.should be_false
- @io.closed_write?.should be_false
+ @io.closed_read?.should == false
+ @io.closed_write?.should == false
@io.string.should == "reopened, another time"
end
@@ -31,16 +31,16 @@ describe "StringIO#reopen when passed [Object, Integer]" do
end
it "raises a TypeError when the passed Object can't be converted to a String" do
- -> { @io.reopen(Object.new, IO::RDWR) }.should raise_error(TypeError)
+ -> { @io.reopen(Object.new, IO::RDWR) }.should.raise(TypeError)
end
it "raises an Errno::EACCES when trying to reopen self with a frozen String in write-mode" do
- -> { @io.reopen("burn".freeze, IO::WRONLY) }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should raise_error(Errno::EACCES)
+ -> { @io.reopen("burn".freeze, IO::WRONLY) }.should.raise(Errno::EACCES)
+ -> { @io.reopen("burn".freeze, IO::WRONLY | IO::APPEND) }.should.raise(Errno::EACCES)
end
it "raises a FrozenError when trying to reopen self with a frozen String in truncate-mode" do
- -> { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should raise_error(FrozenError)
+ -> { @io.reopen("burn".freeze, IO::RDONLY | IO::TRUNC) }.should.raise(FrozenError)
end
it "does not raise IOError when passed a frozen String in read-mode" do
@@ -51,28 +51,28 @@ end
describe "StringIO#reopen when passed [Object, Object]" do
before :each do
- @io = StringIO.new(+"example")
+ @io = StringIO.new("example")
end
it "reopens self with the passed Object in the passed mode" do
- @io.reopen(+"reopened", "r")
- @io.closed_read?.should be_false
- @io.closed_write?.should be_true
+ @io.reopen("reopened", "r")
+ @io.closed_read?.should == false
+ @io.closed_write?.should == true
@io.string.should == "reopened"
@io.reopen(+"reopened, twice", "r+")
- @io.closed_read?.should be_false
- @io.closed_write?.should be_false
+ @io.closed_read?.should == false
+ @io.closed_write?.should == false
@io.string.should == "reopened, twice"
@io.reopen(+"reopened, another", "w+")
- @io.closed_read?.should be_false
- @io.closed_write?.should be_false
+ @io.closed_read?.should == false
+ @io.closed_write?.should == false
@io.string.should == ""
@io.reopen(+"reopened, another time", "r+")
- @io.closed_read?.should be_false
- @io.closed_write?.should be_false
+ @io.closed_read?.should == false
+ @io.closed_write?.should == false
@io.string.should == "reopened, another time"
end
@@ -83,41 +83,41 @@ describe "StringIO#reopen when passed [Object, Object]" do
it "tries to convert the passed Object to a String using #to_str" do
obj = mock("to_str")
- obj.should_receive(:to_str).and_return(+"to_str")
+ obj.should_receive(:to_str).and_return("to_str")
@io.reopen(obj, "r")
@io.string.should == "to_str"
end
it "raises a TypeError when the passed Object can't be converted to a String using #to_str" do
- -> { @io.reopen(Object.new, "r") }.should raise_error(TypeError)
+ -> { @io.reopen(Object.new, "r") }.should.raise(TypeError)
end
it "resets self's position to 0" do
@io.read(5)
@io.reopen(+"reopened")
- @io.pos.should eql(0)
+ @io.pos.should.eql?(0)
end
it "resets self's line number to 0" do
@io.gets
@io.reopen(+"reopened")
- @io.lineno.should eql(0)
+ @io.lineno.should.eql?(0)
end
it "tries to convert the passed mode Object to an Integer using #to_str" do
obj = mock("to_str")
obj.should_receive(:to_str).and_return("r")
- @io.reopen(+"reopened", obj)
- @io.closed_read?.should be_false
- @io.closed_write?.should be_true
+ @io.reopen("reopened", obj)
+ @io.closed_read?.should == false
+ @io.closed_write?.should == true
@io.string.should == "reopened"
end
it "raises an Errno::EACCES error when trying to reopen self with a frozen String in write-mode" do
- -> { @io.reopen("burn".freeze, 'w') }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, 'w+') }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, 'a') }.should raise_error(Errno::EACCES)
- -> { @io.reopen("burn".freeze, "r+") }.should raise_error(Errno::EACCES)
+ -> { @io.reopen("burn".freeze, 'w') }.should.raise(Errno::EACCES)
+ -> { @io.reopen("burn".freeze, 'w+') }.should.raise(Errno::EACCES)
+ -> { @io.reopen("burn".freeze, 'a') }.should.raise(Errno::EACCES)
+ -> { @io.reopen("burn".freeze, "r+") }.should.raise(Errno::EACCES)
end
it "does not raise IOError if a frozen string is passed in read mode" do
@@ -128,7 +128,7 @@ end
describe "StringIO#reopen when passed [String]" do
before :each do
- @io = StringIO.new(+"example")
+ @io = StringIO.new("example")
end
it "reopens self with the passed String in read-write mode" do
@@ -136,8 +136,8 @@ describe "StringIO#reopen when passed [String]" do
@io.reopen(+"reopened")
- @io.closed_write?.should be_false
- @io.closed_read?.should be_false
+ @io.closed_write?.should == false
+ @io.closed_read?.should == false
@io.string.should == "reopened"
end
@@ -145,29 +145,29 @@ describe "StringIO#reopen when passed [String]" do
it "resets self's position to 0" do
@io.read(5)
@io.reopen(+"reopened")
- @io.pos.should eql(0)
+ @io.pos.should.eql?(0)
end
it "resets self's line number to 0" do
@io.gets
@io.reopen(+"reopened")
- @io.lineno.should eql(0)
+ @io.lineno.should.eql?(0)
end
end
describe "StringIO#reopen when passed [Object]" do
before :each do
- @io = StringIO.new(+"example")
+ @io = StringIO.new("example")
end
it "raises a TypeError when passed an Object that can't be converted to a StringIO" do
- -> { @io.reopen(Object.new) }.should raise_error(TypeError)
+ -> { @io.reopen(Object.new) }.should.raise(TypeError)
end
it "does not try to convert the passed Object to a String using #to_str" do
obj = mock("not to_str")
obj.should_not_receive(:to_str)
- -> { @io.reopen(obj) }.should raise_error(TypeError)
+ -> { @io.reopen(obj) }.should.raise(TypeError)
end
it "tries to convert the passed Object to a StringIO using #to_strio" do
@@ -180,26 +180,26 @@ end
describe "StringIO#reopen when passed no arguments" do
before :each do
- @io = StringIO.new(+"example\nsecond line")
+ @io = StringIO.new("example\nsecond line")
end
it "resets self's mode to read-write" do
@io.close
@io.reopen
- @io.closed_read?.should be_false
- @io.closed_write?.should be_false
+ @io.closed_read?.should == false
+ @io.closed_write?.should == false
end
it "resets self's position to 0" do
@io.read(5)
@io.reopen
- @io.pos.should eql(0)
+ @io.pos.should.eql?(0)
end
it "resets self's line number to 0" do
@io.gets
@io.reopen
- @io.lineno.should eql(0)
+ @io.lineno.should.eql?(0)
end
end
@@ -208,7 +208,7 @@ end
# for details.
describe "StringIO#reopen" do
before :each do
- @io = StringIO.new(+'hello','a')
+ @io = StringIO.new(+'hello', 'a')
end
# TODO: find out if this is really a bug