Sha256: e5fa0469189c2b5ae92cf9d34efd3685bfa80e54f05a6182e70fd0adac34a0ac
Contents?: true
Size: 1.24 KB
Versions: 83
Compression:
Stored size: 1.24 KB
Contents
# encoding: utf-8 require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper' require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes' ruby_version_is '1.8.7' do describe "IO#getbyte" do before :each do @original = $KCODE $KCODE = "UTF-8" @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? $KCODE = @original end it "returns the next byte from the stream" do @file.readline.should == "Voici la ligne une.\n" letters = @file.getbyte, @file.getbyte, @file.getbyte, @file.getbyte, @file.getbyte letters.should == [81, 117, 105, 32, 195] end it "returns nil when invoked at the end of the stream" do # read entire content @file.read @file.getbyte.should == nil end it "returns nil on empty stream" do File.open(tmp('empty.txt'), "w+") { |empty| empty.getbyte.should == nil } File.unlink(tmp("empty.txt")) end it "raises IOError on closed stream" do lambda { IOSpecs.closed_file.getbyte }.should raise_error(IOError) end end end
Version data entries
83 entries across 83 versions & 1 rubygems