diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 11f5e36..550ef74 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -112,7 +112,8 @@ module FakeFS if path.respond_to? :entry path.entry.is_a? MockDir else - FileSystem.find(path).entry.is_a? MockDir + result = FileSystem.find(path) + result ? result.entry.is_a?(MockDir) : false end end diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 058df0d..c32a657 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -42,6 +42,11 @@ class FakeFSTest < Test::Unit::TestCase assert File.directory?(sympath) 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 FileUtils.mkdir_p(path = "/path/to/dir") assert File.exists?(path)