Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1491,7 +1491,8 @@ def remove_file(path, force = false)
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
#
def remove_dir(path, force = false)
remove_entry path, force # FIXME?? check if it is a directory
raise Errno::ENOTDIR, path unless File.directory?(path)
remove_entry path, force
end
module_function :remove_dir

Expand Down
8 changes: 8 additions & 0 deletions test/fileutils/test_fileutils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,14 @@ def test_remove_dir_file_perm
assert_file_not_exist 'data/tmpdir'
end if have_file_perm?

def test_remove_dir_with_file
File.write('data/tmpfile', 'dummy')
assert_raise(Errno::ENOTDIR) { remove_dir 'data/tmpfile' }
assert_file_exist 'data/tmpfile'
ensure
File.unlink('data/tmpfile') if File.exist?('data/tmpfile')
end

def test_compare_file
check_singleton :compare_file
# FIXME
Expand Down