Sha256: 2e4321a668018b1ee62c46f7c8a4de73d49735c761022ff871f841fe31233ea1
Contents?: true
Size: 1.67 KB
Versions: 83
Compression:
Stored size: 1.67 KB
Contents
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper' require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes' describe "IO#readchar" do before :each do @file_name = File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/readlines.txt' @file = File.open(@file_name, 'r') end after :each do @file.close unless @file.closed? end ruby_version_is "" ... "1.9" do it "returns the next byte from the stream" do @file.readchar.should == 86 @file.readchar.should == 111 @file.readchar.should == 105 # read the rest of line @file.readline.should == "ci la ligne une.\n" @file.readchar.should == 81 end end ruby_version_is "1.9" do it "returns the next string from the stream" do @file.readchar.should == 'V' @file.readchar.should == 'o' @file.readchar.should == 'i' # read the rest of line @file.readline.should == "ci la ligne une.\n" @file.readchar.should == 'Q' end end it "raises EOFError when invoked at the end of the stream" do # read entire content @file.read lambda { @file.readchar }.should raise_error(EOFError) end it "raises EOFError when reaches the end of the stream" do lambda { loop { @file.readchar } }.should raise_error(EOFError) end it "raises EOFError on empty stream" do File.open(tmp('empty.txt'), "w+") { |empty| lambda { empty.readchar }.should raise_error(EOFError) } File.unlink(tmp("empty.txt")) end it "raises IOError on closed stream" do lambda { IOSpecs.closed_file.readchar }.should raise_error(IOError) end end
Version data entries
83 entries across 83 versions & 1 rubygems