Sha256: fc59ef930724ccb3fc96256df59af52134a5d7eaf971018216b07c3bcecf724e
Contents?: true
Size: 1.45 KB
Versions: 83
Compression:
Stored size: 1.45 KB
Contents
# -*- encoding: utf-8 -*- require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper' require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes' describe "IO#readline" do it "returns the next line on the stream" do testfile = File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/gets.txt' f = File.open(testfile, 'r') do |f| f.readline.should == "Voici la ligne une.\n" f.readline.should == "Qui รจ la linea due.\n" end end it "goes back to first position after a rewind" do testfile = File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/gets.txt' f = File.open(testfile, 'r') do |f| f.readline.should == "Voici la ligne une.\n" f.rewind f.readline.should == "Voici la ligne une.\n" end end it "is modified by the cursor position" do testfile = File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/gets.txt' f = File.open(testfile, 'r') do |f| f.seek(1) f.readline.should == "oici la ligne une.\n" end end it "raises EOFError on end of stream" do testfile = File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/gets.txt' File.open(testfile, 'r') do |f| lambda { loop { f.readline } }.should raise_error(EOFError) end end it "raises IOError on closed stream" do lambda { IOSpecs.closed_file.readline }.should raise_error(IOError) end end
Version data entries
83 entries across 83 versions & 1 rubygems