Adding File.size? too
This commit is contained in:
parent
166ff444d9
commit
e591d3b2d3
@ -50,6 +50,10 @@ module FakeFS
|
||||
read(path).length
|
||||
end
|
||||
|
||||
def self.size?(path)
|
||||
exists?(path) && !size(path).zero?
|
||||
end
|
||||
|
||||
def self.const_missing(name)
|
||||
RealFile.const_get(name)
|
||||
end
|
||||
|
@ -208,6 +208,23 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
assert_equal 9, File.size(path)
|
||||
end
|
||||
|
||||
def test_can_check_if_file_has_size?
|
||||
path = '/path/to/file.txt'
|
||||
File.open(path, 'w') do |f|
|
||||
f << 'Yada Yada'
|
||||
end
|
||||
assert File.size?(path)
|
||||
assert ! File.size?("/path/to/other.txt")
|
||||
end
|
||||
|
||||
def test_can_check_size?_of_empty_file
|
||||
path = '/path/to/file.txt'
|
||||
File.open(path, 'w') do |f|
|
||||
f << ''
|
||||
end
|
||||
assert ! File.size?("/path/to/file.txt")
|
||||
end
|
||||
|
||||
def test_can_read_with_File_readlines
|
||||
path = '/path/to/file.txt'
|
||||
File.open(path, 'w') do |f|
|
||||
|
Loading…
Reference in New Issue
Block a user