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.3.2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.2.beta.2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.2.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.1.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.0 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.0.beta.3 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.0.beta.2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.3.0.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.6 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.6.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.5 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.5.beta.3 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.5.beta.2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.5.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.4.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.3 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.3.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.2 spec/framework_spec/app/spec/core/dir/close_spec.rb
rhodes-2.2.2.beta.1 spec/framework_spec/app/spec/core/dir/close_spec.rb