Sha256: 082d5474e0d15ed0fed5481ccc033125129ef22e3f6fcac72006e512d446d967

Contents?: true

Size: 1.16 KB

Versions: 83

Compression:

Stored size: 1.16 KB

Contents

require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/classes'
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/shared/write'

describe "IO#write_nonblock on a file" do
  before :each do
    @filename = tmp("IO_syswrite_file") + $$.to_s
    File.open(@filename, "w") do |file|
      file.write_nonblock("012345678901234567890123456789")
    end
    @file = File.open(@filename, "r+")
    @readonly_file = File.open(@filename)
  end

  after :each do
    @file.close
    @readonly_file.close
    File.delete(@filename)
  end

  it "writes all of the string's bytes but does not buffer them" do
    written = @file.write_nonblock("abcde")
    written.should == 5
    File.open(@filename) do |file|
      file.sysread(10).should == "abcde56789"
      file.seek(0)
      @file.fsync
      file.sysread(10).should == "abcde56789"
    end
  end

  it "checks if the file is writable if writing zero bytes" do
    lambda { @readonly_file.write_nonblock("") }.should raise_error
  end
end

describe "IO#write_nonblock" do
  it_behaves_like :io_write, :write_nonblock
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
rhodes-3.1.1 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.1.1.beta spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.1.0 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.1.0.beta.5 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.1.0.beta.4 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.1.0.beta.3 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.1.0.beta.2 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.1.0.beta.1 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.2 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.2.beta.1 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1.beta.8 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1.beta.7 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1.beta.6 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1.beta.5 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1.beta.4 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1.beta.3 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.1.beta.2 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.0 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb
rhodes-3.0.0.beta.7 spec/framework_spec/app/spec/core/io/write_nonblock_spec.rb