Sha256: 6d6d98f1ce62b903eb8380a8439722e0d0565fd9c135b249d154686d25b0ae64

Contents?: true

Size: 1.56 KB

Versions: 52

Compression:

Stored size: 1.56 KB

Contents

# -*- encoding: ascii-8bit -*-
describe :io_putc, :shared => true do
  after :each do
    @io.close unless @io.closed?
    @io_object = nil
    rm_r @name
  end

  describe "with a Fixnum argument" do
    it "writes one character as a String" do
      @io.should_receive(:write).with("A")
      @io_object.send(@method, 65).should == 65
    end

    it "writes the low byte as a String" do
      @io.should_receive(:write).with("A")
      @io_object.send(@method, 0x2441).should == 0x2441
    end
  end

  describe "with a String argument" do
    it "writes one character" do
      @io.should_receive(:write).with("B")
      @io_object.send(@method, "B").should == "B"
    end

    it "writes the first character" do
      @io.should_receive(:write).with("R")
      @io_object.send(@method, "Ruby").should == "Ruby"
    end
  end

  it "calls #to_int to convert an object to a Integer" do
    obj = mock("kernel putc")
    obj.should_receive(:to_int).and_return(65)

    @io.should_receive(:write).with("A")
    @io_object.send(@method, obj).should == obj
  end

  it "raises IOError on a closed stream" do
    @io.close
    lambda { @io_object.send(@method, "a") }.should raise_error(IOError)
  end

  it "raises an TypeError when passed nil" do
    lambda { @io_object.send(@method, nil) }.should raise_error(TypeError)
  end

  it "raises an TypeError when passed false" do
    lambda { @io_object.send(@method, false) }.should raise_error(TypeError)
  end

  it "raises an TypeError when passed true" do
    lambda { @io_object.send(@method, true) }.should raise_error(TypeError)
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-7.5.1 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-7.4.1 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-7.1.17 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-6.2.0 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-6.0.11 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.18 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.17 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.15 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.0.22 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.2 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.0.7 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.0.3 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-5.5.0 spec/framework_spec/app/spec/shared/io/putc.rb
tauplatform-1.0.3 spec/framework_spec/app/spec/shared/io/putc.rb
tauplatform-1.0.2 spec/framework_spec/app/spec/shared/io/putc.rb
tauplatform-1.0.1 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-3.5.1.12 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-3.3.5 spec/framework_spec/app/spec/shared/io/putc.rb
rhodes-3.4.2 spec/framework_spec/app/spec/shared/io/putc.rb