From 5deda9b4567f64f824700a0eccc894cc5a7919b2 Mon Sep 17 00:00:00 2001 From: Nick Quaranto Date: Tue, 29 Sep 2009 11:21:12 -0400 Subject: [PATCH] File.size? actually returns nil instead of false --- lib/fakefs/file.rb | 6 +++++- test/fakefs_test.rb | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 793819c..0706f76 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -51,7 +51,11 @@ module FakeFS end def self.size?(path) - exists?(path) && !size(path).zero? + if exists?(path) && !size(path).zero? + true + else + nil + end end def self.const_missing(name) diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index ae46b4b..564db4b 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -214,7 +214,7 @@ class FakeFSTest < Test::Unit::TestCase f << 'Yada Yada' end assert File.size?(path) - assert ! File.size?("/path/to/other.txt") + assert_nil File.size?("/path/to/other.txt") end def test_can_check_size?_of_empty_file @@ -222,7 +222,7 @@ class FakeFSTest < Test::Unit::TestCase File.open(path, 'w') do |f| f << '' end - assert ! File.size?("/path/to/file.txt") + assert_nil File.size?("/path/to/file.txt") end def test_can_read_with_File_readlines