Implemented File.size
This commit is contained in:
parent
0da41d92a7
commit
a34f8e8beb
@ -18,6 +18,10 @@ module FakeFS
|
|||||||
alias_method :exists?, :exist?
|
alias_method :exists?, :exist?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.size(path)
|
||||||
|
read(path).length
|
||||||
|
end
|
||||||
|
|
||||||
def self.const_missing(name)
|
def self.const_missing(name)
|
||||||
RealFile.const_get(name)
|
RealFile.const_get(name)
|
||||||
end
|
end
|
||||||
|
@ -113,6 +113,14 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
assert_equal 'Yada Yada', File.read(path)
|
assert_equal 'Yada Yada', File.read(path)
|
||||||
end
|
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
|
def test_can_read_with_File_readlines
|
||||||
path = '/path/to/file.txt'
|
path = '/path/to/file.txt'
|
||||||
File.open(path, 'w') do |f|
|
File.open(path, 'w') do |f|
|
||||||
|
Loading…
Reference in New Issue
Block a user