Sha256: a565c61da02943e801010c564a85e0edaca658d089daa1d6573785d2ab6341c9
Contents?: true
Size: 1.31 KB
Versions: 83
Compression:
Stored size: 1.31 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 on a file" do before :each do @filename = tmp("IO_syswrite_file") + $$.to_s File.open(@filename, "w") do |file| file.write("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 # TODO: impl detail? discuss this with matz. This spec is useless. - rdavis it "writes all of the string's bytes but buffers them" do written = @file.write("abcde") written.should == 5 File.open(@filename) do |file| file.read.should == "012345678901234567890123456789" @file.fsync file.rewind file.read.should == "abcde5678901234567890123456789" end end it "does not check if the file is writable if writing zero bytes" do lambda { @readonly_file.write("") }.should_not raise_error end it "returns a length of 0 when writing a blank string" do @file.write('').should == 0 end end describe "IO#write" do it_behaves_like :io_write, :write end
Version data entries
83 entries across 83 versions & 1 rubygems