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

Version Path
rhodes-3.0.0.beta.6 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-3.0.0.beta.5 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-3.0.0.beta.4 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-3.0.0.beta.3 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-3.0.0.beta.2 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-3.0.0.beta.1 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.4.1 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.4.1.beta.1 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.4.0 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.4.0.beta.2 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.4.0.beta.1 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.2 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.2.beta.2 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.2.beta.1 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.1 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.1.beta.1 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.0 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.0.beta.3 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.0.beta.2 spec/framework_spec/app/spec/core/io/readline_spec.rb
rhodes-2.3.0.beta.1 spec/framework_spec/app/spec/core/io/readline_spec.rb