From 94afbcabc14bd4d747e4101ea9e31f1ae4948c06 Mon Sep 17 00:00:00 2001 From: Pat Nakajima Date: Fri, 12 Jun 2009 17:54:32 -0400 Subject: [PATCH] Fixed File.file? for non-existent files --- lib/fakefs.rb | 3 ++- test/fakefs_test.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/fakefs.rb b/lib/fakefs.rb index b834af1..54913b0 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -128,7 +128,8 @@ module FakeFS if path.respond_to? :entry path.entry.is_a? MockFile else - FileSystem.find(path).entry.is_a? MockFile + result = FileSystem.find(path) + result && result.entry.is_a?(MockFile) end end diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 26a9038..36abfd7 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -133,6 +133,10 @@ class FakeFSTest < Test::Unit::TestCase assert File.file?(sympath) end + def test_knows_non_existent_files_arent_files + assert ! File.file?('does/not/exist.txt') + end + def test_can_chown_files good = 'file.txt' bad = 'nofile.txt'