raise Errno::EEXIST when Dir.mkdir is called with an existing directory. Closes #21.
This commit is contained in:
parent
ceffec3023
commit
bdb3fa4ac0
@ -86,6 +86,7 @@ module FakeFS
|
||||
parent = string.split('/')
|
||||
parent.pop
|
||||
raise Errno::ENOENT, "No such file or directory - #{string}" unless parent.join == "" || FileSystem.find(parent.join('/'))
|
||||
raise Errno::EEXIST, "File exists - #{string}" if File.exists?(string)
|
||||
FileUtils.mkdir_p(string)
|
||||
end
|
||||
|
||||
|
@ -1102,6 +1102,14 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_mkdir_raises_error_if_already_created
|
||||
Dir.mkdir "foo"
|
||||
|
||||
assert_raises(Errno::EEXIST) do
|
||||
Dir.mkdir "foo"
|
||||
end
|
||||
end
|
||||
|
||||
def test_directory_open
|
||||
test = ['.', '..', 'file_1', 'file_2', 'file_3', 'file_4', 'file_5' ]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user