FileUtils#rm and File#delete should raise Errno::ENOENT when any file
does not exist (Closes #70)
This commit is contained in:
parent
47b34075a8
commit
4da1d58d66
@ -68,6 +68,7 @@ module FakeFS
|
||||
def delete(path)
|
||||
if node = FileSystem.find(path)
|
||||
node.delete
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -30,7 +30,7 @@ module FakeFS
|
||||
|
||||
def rm(list, options = {})
|
||||
Array(list).each do |path|
|
||||
FileSystem.delete(path)
|
||||
FileSystem.delete(path) or raise Errno::ENOENT.new(path)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -65,6 +65,12 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
assert_kind_of FakeDir, FileSystem.fs['path']['to']['dir']
|
||||
end
|
||||
|
||||
def test_unlink_errors_on_file_not_found
|
||||
assert_raise Errno::ENOENT do
|
||||
FileUtils.rm("/foo")
|
||||
end
|
||||
end
|
||||
|
||||
def test_can_delete_directories
|
||||
FileUtils.mkdir_p("/path/to/dir")
|
||||
FileUtils.rmdir("/path/to/dir")
|
||||
@ -1582,14 +1588,6 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_delete_does_not_raise_error_when_second_file_does_not_exist
|
||||
FileUtils.touch("/foo")
|
||||
|
||||
assert_nothing_raised do
|
||||
File.delete("/foo", "/bar")
|
||||
end
|
||||
end
|
||||
|
||||
def test_unlink_is_alias_for_delete
|
||||
assert_equal File.method(:unlink), File.method(:delete)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user