Permalink
Browse files

don't overwrite existing directories yet

  • Loading branch information...
1 parent 384d58e commit d8aa9f38fc00477a776fc3aac8dd5b975846318a @defunkt defunkt committed May 29, 2009
Showing with 9 additions and 2 deletions.
  1. +2 −2 lib/fakefs.rb
  2. +7 −0 test/fakefs_test.rb
View
@@ -43,7 +43,7 @@ def self.join(*parts)
end
def self.exists?(path)
- FileSystem.find(path)
+ FileSystem.find(path) || false
end
def self.directory?(path)
@@ -152,7 +152,7 @@ def add(path, object=MockDir.new)
object.name = parts.last
object.parent = d
- d[parts.last] = object
+ d[parts.last] ||= object
end
# copies directories and files from the real filesystem
View
@@ -36,6 +36,13 @@ def test_knows_directories_are_directories
assert File.directory?(path)
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
FileUtils.mkdir_p(target = "/path/to/target")
FileUtils.ln_s(target, "/path/to/link")

0 comments on commit d8aa9f3

Please sign in to comment.