diff options
Diffstat (limited to 'spec/ruby/core/dir/shared/delete.rb')
| -rw-r--r-- | spec/ruby/core/dir/shared/delete.rb | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/spec/ruby/core/dir/shared/delete.rb b/spec/ruby/core/dir/shared/delete.rb index 8db17d985f..a81b059759 100644 --- a/spec/ruby/core/dir/shared/delete.rb +++ b/spec/ruby/core/dir/shared/delete.rb @@ -17,24 +17,14 @@ describe :dir_delete, shared: true do Dir.send(@method, p) end - platform_is_not :solaris do - it "raises an Errno::ENOTEMPTY when trying to remove a nonempty directory" do - lambda do - Dir.send @method, DirSpecs.mock_rmdir("nonempty") - end.should raise_error(Errno::ENOTEMPTY) - end - end - - platform_is :solaris do - it "raises an Errno::EEXIST when trying to remove a nonempty directory" do - lambda do - Dir.send @method, DirSpecs.mock_rmdir("nonempty") - end.should raise_error(Errno::EEXIST) - end + it "raises an Errno::ENOTEMPTY when trying to remove a nonempty directory" do + -> do + Dir.send @method, DirSpecs.mock_rmdir("nonempty") + end.should raise_error(Errno::ENOTEMPTY) end it "raises an Errno::ENOENT when trying to remove a non-existing directory" do - lambda do + -> do Dir.send @method, DirSpecs.nonexistent end.should raise_error(Errno::ENOENT) end @@ -42,20 +32,22 @@ describe :dir_delete, shared: true do it "raises an Errno::ENOTDIR when trying to remove a non-directory" do file = DirSpecs.mock_rmdir("nonempty/regular") touch(file) - lambda do + -> do Dir.send @method, file end.should raise_error(Errno::ENOTDIR) end # this won't work on Windows, since chmod(0000) does not remove all permissions platform_is_not :windows do - it "raises an Errno::EACCES if lacking adequate permissions to remove the directory" do - parent = DirSpecs.mock_rmdir("noperm") - child = DirSpecs.mock_rmdir("noperm", "child") - File.chmod(0000, parent) - lambda do - Dir.send @method, child - end.should raise_error(Errno::EACCES) + as_user do + it "raises an Errno::EACCES if lacking adequate permissions to remove the directory" do + parent = DirSpecs.mock_rmdir("noperm") + child = DirSpecs.mock_rmdir("noperm", "child") + File.chmod(0000, parent) + -> do + Dir.send @method, child + end.should raise_error(Errno::EACCES) + end end end end |
