1 require File.dirname(__FILE__) + '/../../spec_helper'
2 require File.dirname(__FILE__) + '/fixtures/classes'
4 describe "IO#rewind" do
6 @file = File.open(File.dirname(__FILE__) + '/fixtures/readlines.txt', 'r')
7 @io = IO.open @file.fileno, 'r'
11 # we *must* close both in order to not leak descriptors
12 @io.close unless @io.closed?
13 @file.close unless @file.closed? rescue Errno::EBADF
16 it "positions the instance to the beginning of input" do
17 @io.readline.should == "Voici la ligne une.\n"
18 @io.readline.should == "Qui รจ la linea due.\n"
20 @io.readline.should == "Voici la ligne une.\n"
23 it "sets lineno to 0" do
24 @io.readline.should == "Voici la ligne une.\n"
25 @io.lineno.should == 1
27 @io.lineno.should == 0
30 it "raises IOError on closed stream" do
31 lambda { IOSpecs.closed_file.rewind }.should raise_error(IOError)