Implemented File.size

This commit is contained in:
Jon Yurek 2009-09-29 22:03:21 +08:00 committed by Chris Wanstrath
parent 0da41d92a7
commit a34f8e8beb
2 changed files with 12 additions and 0 deletions

View File

@ -18,6 +18,10 @@ module FakeFS
alias_method :exists?, :exist?
end
def self.size(path)
read(path).length
end
def self.const_missing(name)
RealFile.const_get(name)
end

View File

@ -113,6 +113,14 @@ class FakeFSTest < Test::Unit::TestCase
assert_equal 'Yada Yada', File.read(path)
end
def test_can_get_size_of_files
path = '/path/to/file.txt'
File.open(path, 'w') do |f|
f << 'Yada Yada'
end
assert_equal 9, File.size(path)
end
def test_can_read_with_File_readlines
path = '/path/to/file.txt'
File.open(path, 'w') do |f|