don't overwrite existing directories yet

This commit is contained in:
Chris Wanstrath 2009-05-29 11:00:44 -07:00
parent 384d58e736
commit d8aa9f38fc
2 changed files with 9 additions and 2 deletions

View File

@ -43,7 +43,7 @@ module FakeFS
end end
def self.exists?(path) def self.exists?(path)
FileSystem.find(path) FileSystem.find(path) || false
end end
def self.directory?(path) def self.directory?(path)
@ -152,7 +152,7 @@ module FakeFS
object.name = parts.last object.name = parts.last
object.parent = d object.parent = d
d[parts.last] = object d[parts.last] ||= object
end end
# copies directories and files from the real filesystem # copies directories and files from the real filesystem

View File

@ -36,6 +36,13 @@ class FakeFSTest < Test::Unit::TestCase
assert File.directory?(path) assert File.directory?(path)
end end
def test_doesnt_overwrite_existing_directories
FileUtils.mkdir_p(path = "/path/to/dir")
assert File.exists?(path)
FileUtils.mkdir_p("/path/to")
assert File.exists?(path)
end
def test_can_create_symlinks def test_can_create_symlinks
FileUtils.mkdir_p(target = "/path/to/target") FileUtils.mkdir_p(target = "/path/to/target")
FileUtils.ln_s(target, "/path/to/link") FileUtils.ln_s(target, "/path/to/link")