Sha256: 2ae9f1dd3cde511d2081384a771058cafbc36098e05f6938e22d9045e26afce8

Contents?: true

Size: 945 Bytes

Versions: 52

Compression:

Stored size: 945 Bytes

Contents

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

describe "Dir#close" do
  platform_is_not :windows do
  it "closes the stream and fd and returns nil" do
    # This is a bit convoluted but we are trying to ensure the file gets closed.
    # To do that, we peek to see what the next FD number is and then probe that
    # to see whether it has been closed.
    peek = IO.sysopen DirSpecs.mock_dir
    File.for_fd(peek).close

    dir = Dir.open DirSpecs.mock_dir
    File.for_fd(peek).close                   # Should be open here

    dir.close.should == nil
    lambda { File.for_fd(peek).close }.should raise_error(SystemCallError)  # And closed here
    end
  end
end

describe "Dir#close" do
  it_behaves_like :dir_closed, :close
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
rhodes-2.0.0.beta3 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.5.5 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.0.0.beta2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.0.0.beta1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.5.4 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.5.3 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.5.2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.5.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.5.0 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.4.2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.4.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-1.4.0 spec/framework_spec/app/spec/core/dir/close_spec.rb