Sha256: a91338e139681854021d7858f13385de843f93f0b6bd2bef687dac8a94a3e511
Contents?: true
Size: 1.94 KB
Versions: 24
Compression:
Stored size: 1.94 KB
Contents
require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/../../spec_helper' require File.dirname(File.join(__rhoGetCurrentDir(), __FILE__)) + '/fixtures/common' describe "Dir.mkdir" do it "creates the named directory with the given permissions" do DirSpecs.clear_dirs begin File.exist?('nonexisting').should == false Dir.mkdir 'nonexisting' File.exist?('nonexisting').should == true platform_is_not :windows do Dir.mkdir 'default_perms' a = File.stat('default_perms').mode Dir.mkdir 'reduced', (a - 1) File.stat('reduced').mode.should_not == a end platform_is :windows do Dir.mkdir 'default_perms', 0666 a = File.stat('default_perms').mode Dir.mkdir 'reduced', 0444 File.stat('reduced').mode.should_not == a end Dir.mkdir('always_returns_0').should == 0 platform_is_not(:windows) do File.chmod(0777, "nonexisting","default_perms","reduced","always_returns_0") end platform_is_not(:windows) do File.chmod(0644, "nonexisting","default_perms","reduced","always_returns_0") end ensure DirSpecs.clear_dirs end end it "raises a SystemCallError when lacking adequate permissions in the parent dir" do # In case something happened it it didn't get cleaned up. if File.exist? 'noperms' File.chmod 0777, "noperms" FileUtils.rm_rf 'noperms' end Dir.mkdir 'noperms', 0000 lambda { Dir.mkdir 'noperms/subdir' }.should raise_error(SystemCallError) system 'chmod 0777 noperms' platform_is_not :windows do File.chmod 0777, "noperms" end platform_is :windows do File.chmod 0666, "noperms" end Dir.rmdir 'noperms' end it "raises a SystemCallError if any of the directories in the path before the last does not exist" do lambda { Dir.mkdir "#{DirSpecs.nonexistent}/subdir" }.should raise_error(SystemCallError) end end
Version data entries
24 entries across 24 versions & 1 rubygems