summaryrefslogtreecommitdiff
path: root/spec/ruby/core/io/eof_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/io/eof_spec.rb')
-rw-r--r--spec/ruby/core/io/eof_spec.rb40
1 files changed, 20 insertions, 20 deletions
diff --git a/spec/ruby/core/io/eof_spec.rb b/spec/ruby/core/io/eof_spec.rb
index a2c5e563f0..c8955abde0 100644
--- a/spec/ruby/core/io/eof_spec.rb
+++ b/spec/ruby/core/io/eof_spec.rb
@@ -1,5 +1,5 @@
-require File.expand_path('../../../spec_helper', __FILE__)
-require File.expand_path('../fixtures/classes', __FILE__)
+require_relative '../../spec_helper'
+require_relative 'fixtures/classes'
describe "IO#eof?" do
before :each do
@@ -12,13 +12,13 @@ describe "IO#eof?" do
end
it "returns true on an empty stream that has just been opened" do
- File.open(@name) { |empty| empty.eof?.should == true }
+ File.open(@name) { |empty| empty.should.eof? }
end
it "raises IOError on stream not opened for reading" do
- lambda do
+ -> do
File.open(@name, "w") { |f| f.eof? }
- end.should raise_error(IOError)
+ end.should.raise(IOError)
end
end
@@ -34,51 +34,51 @@ describe "IO#eof?" do
it "returns false when not at end of file" do
@io.read 1
- @io.eof?.should == false
+ @io.should_not.eof?
end
it "returns true after reading with read with no parameters" do
@io.read()
- @io.eof?.should == true
+ @io.should.eof?
end
it "returns true after reading with read" do
@io.read(File.size(@name))
- @io.eof?.should == true
+ @io.should.eof?
end
it "returns true after reading with sysread" do
@io.sysread(File.size(@name))
- @io.eof?.should == true
+ @io.should.eof?
end
it "returns true after reading with readlines" do
@io.readlines
- @io.eof?.should == true
+ @io.should.eof?
end
it "returns false on just opened non-empty stream" do
- @io.eof?.should == false
+ @io.should_not.eof?
end
it "does not consume the data from the stream" do
- @io.eof?.should == false
+ @io.should_not.eof?
@io.getc.should == 'V'
end
it "raises IOError on closed stream" do
- lambda { IOSpecs.closed_io.eof? }.should raise_error(IOError)
+ -> { IOSpecs.closed_io.eof? }.should.raise(IOError)
end
it "raises IOError on stream closed for reading by close_read" do
@io.close_read
- lambda { @io.eof? }.should raise_error(IOError)
+ -> { @io.eof? }.should.raise(IOError)
end
it "returns true on one-byte stream after single-byte read" do
- File.open(File.dirname(__FILE__) + '/fixtures/one_byte.txt') { |one_byte|
+ File.open(__dir__ + '/fixtures/one_byte.txt') { |one_byte|
one_byte.read(1)
- one_byte.eof?.should == true
+ one_byte.should.eof?
}
end
end
@@ -92,16 +92,16 @@ describe "IO#eof?" do
it "returns true on receiving side of Pipe when writing side is closed" do
@r, @w = IO.pipe
@w.close
- @r.eof?.should == true
+ @r.should.eof?
end
it "returns false on receiving side of Pipe when writing side wrote some data" do
@r, @w = IO.pipe
@w.puts "hello"
- @r.eof?.should == false
+ @r.should_not.eof?
@w.close
- @r.eof?.should == false
+ @r.should_not.eof?
@r.read
- @r.eof?.should == true
+ @r.should.eof?
end
end