From 4530cb1e31ee6e7e2f30c7380444dfd9eeeb9d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mislav=20Marohni=C4=87?= Date: Fri, 27 Nov 2009 13:48:03 +0100 Subject: [PATCH] implement File::Stat#size --- lib/fakefs/file.rb | 4 ++++ test/file/stat_test.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 39caef6..64a5ed0 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -192,6 +192,10 @@ module FakeFS def nlink FileSystem.find(@file).links.size end + + def size + File.size(@file) + end end attr_reader :path diff --git a/test/file/stat_test.rb b/test/file/stat_test.rb index 4121774..d0eaec2 100644 --- a/test/file/stat_test.rb +++ b/test/file/stat_test.rb @@ -67,4 +67,9 @@ class FileStatTest < Test::Unit::TestCase assert_equal 2, File.stat("testfile").nlink end + + def test_file_size + File.open('testfile', 'w') { |f| f << 'test' } + assert_equal 4, File.stat('testfile').size + end end