Sha256: 836d008bd529fc134e911e4c46410f45f8600f43444eb0094ed914a46451809b

Contents?: true

Size: 1.47 KB

Versions: 33

Compression:

Stored size: 1.47 KB

Contents

require File.expand_path('../../../spec_helper', __FILE__)
require File.expand_path('../../../shared/file/sticky', __FILE__)

describe "File.sticky?" do
  it_behaves_like :file_sticky, :sticky?, File
  it_behaves_like :file_sticky_missing, :sticky?, File
end

describe "File.sticky?" do
  it "returns false if file does not exist" do
    if System.get_property('platform') == 'WINDOWS'  
        File.sticky?("I_am_a_bogus_file").should == nil
    else
        File.sticky?("I_am_a_bogus_file").should == false
    end    
  end

  it "returns false if the file has not sticky bit set" do
    filename = tmp("i_exist")
    touch(filename)

    if System.get_property('platform') == 'WINDOWS'  
        File.sticky?(filename).should == nil
    else
        File.sticky?(filename).should == false
    end        
    
    rm_r filename
  end

  platform_is :linux, :darwin do
    it "returns true if the file has sticky bit set" do
      filename = tmp("i_exist")
      touch(filename)
      system "chmod +t #{filename}"
    
      File.sticky?(filename).should == false

      rm_r filename
    end
  end

  platform_is :bsd do
    # FreeBSD and NetBSD can't set stiky bit to a normal file
    it "cannot set sticky bit to a normal file" do
      filename = tmp("i_exist")
      touch(filename)
      stat = File.stat(filename)
      mode = stat.mode
      raise_error(Errno::EFTYPE){File.chmod(mode|01000, filename)}
      File.sticky?(filename).should == false

      rm_r filename
    end
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
rhodes-3.3.5 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.4 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.3 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.3.beta.4 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.3.beta.3 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.3.beta.2 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.3.beta.1 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2.beta.7 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2.beta.6 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2.beta.5 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2.beta.4 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2.beta.3 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2.beta.2 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.2.beta.1 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.1 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.0 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.0.beta.3 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.0.beta.2 spec/framework_spec/app/spec/core/file/sticky_spec.rb
rhodes-3.3.0.beta.1 spec/framework_spec/app/spec/core/file/sticky_spec.rb