Fixed inconsistent File.directory? behavior

This commit is contained in:
Pat Nakajima 2009-06-12 18:22:48 -04:00
parent 57d02ab8b2
commit d7870563aa
2 changed files with 7 additions and 1 deletions

View File

@ -112,7 +112,8 @@ module FakeFS
if path.respond_to? :entry if path.respond_to? :entry
path.entry.is_a? MockDir path.entry.is_a? MockDir
else else
FileSystem.find(path).entry.is_a? MockDir result = FileSystem.find(path)
result ? result.entry.is_a?(MockDir) : false
end end
end end

View File

@ -42,6 +42,11 @@ class FakeFSTest < Test::Unit::TestCase
assert File.directory?(sympath) assert File.directory?(sympath)
end end
def test_knows_non_existent_directories_arent_directories
path = 'does/not/exist/'
assert_equal RealFile.directory?(path), File.directory?(path)
end
def test_doesnt_overwrite_existing_directories def test_doesnt_overwrite_existing_directories
FileUtils.mkdir_p(path = "/path/to/dir") FileUtils.mkdir_p(path = "/path/to/dir")
assert File.exists?(path) assert File.exists?(path)