mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/spec] Temporary directories should be under the mock_dir
This commit is contained in:
parent
56d6cfe88a
commit
32e7d9140e
4 changed files with 22 additions and 18 deletions
|
@ -22,7 +22,7 @@ module DirSpecs
|
|||
[0xe9].pack('U')
|
||||
].each do |dir|
|
||||
begin
|
||||
Dir.rmdir dir
|
||||
Dir.rmdir mock_dir(dir)
|
||||
rescue
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,29 +13,33 @@ describe "Dir.mkdir" do
|
|||
it "creates the named directory with the given permissions" do
|
||||
DirSpecs.clear_dirs
|
||||
|
||||
nonexisting = DirSpecs.mock_dir('nonexisting')
|
||||
default_perms = DirSpecs.mock_dir('default_perms')
|
||||
reduced = DirSpecs.mock_dir('reduced')
|
||||
begin
|
||||
File.should_not.exist?('nonexisting')
|
||||
Dir.mkdir 'nonexisting'
|
||||
File.should.exist?('nonexisting')
|
||||
File.should_not.exist?(nonexisting)
|
||||
Dir.mkdir nonexisting
|
||||
File.should.exist?(nonexisting)
|
||||
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
|
||||
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
|
||||
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
|
||||
always_returns_0 = DirSpecs.mock_dir('always_returns_0')
|
||||
Dir.mkdir(always_returns_0).should == 0
|
||||
platform_is_not(:windows) do
|
||||
File.chmod(0777, "nonexisting","default_perms","reduced","always_returns_0")
|
||||
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")
|
||||
File.chmod(0644, nonexisting, default_perms, reduced, always_returns_0)
|
||||
end
|
||||
ensure
|
||||
DirSpecs.clear_dirs
|
||||
|
@ -45,7 +49,7 @@ describe "Dir.mkdir" do
|
|||
it "calls #to_path on non-String arguments" do
|
||||
DirSpecs.clear_dirs
|
||||
p = mock('path')
|
||||
p.should_receive(:to_path).and_return('nonexisting')
|
||||
p.should_receive(:to_path).and_return(DirSpecs.mock_dir('nonexisting'))
|
||||
Dir.mkdir(p)
|
||||
DirSpecs.clear_dirs
|
||||
end
|
||||
|
|
|
@ -35,7 +35,7 @@ describe :file_world_readable, shared: true do
|
|||
end
|
||||
|
||||
it "returns a Fixnum if the file is a directory and chmod 644" do
|
||||
dir = rand().to_s + '-ww'
|
||||
dir = tmp(rand().to_s + '-ww')
|
||||
Dir.mkdir(dir)
|
||||
Dir.should.exist?(dir)
|
||||
File.chmod(0644, dir)
|
||||
|
|
|
@ -34,7 +34,7 @@ describe :file_world_writable, shared: true do
|
|||
end
|
||||
|
||||
it "returns a Fixnum if the file is a directory and chmod 777" do
|
||||
dir = rand().to_s + '-ww'
|
||||
dir = tmp(rand().to_s + '-ww')
|
||||
Dir.mkdir(dir)
|
||||
Dir.should.exist?(dir)
|
||||
File.chmod(0777, dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue