Added fake FileTest.file? (Closes #94)

This commit is contained in:
Andrius Chamentauskas 2011-08-30 11:19:30 +03:00 committed by Scott Taylor
parent 1e074bf636
commit a0e02ed974
2 changed files with 16 additions and 0 deletions

View File

@ -7,5 +7,9 @@ module FakeFS
def self.directory?(file_name) def self.directory?(file_name)
File.directory?(file_name) File.directory?(file_name)
end end
def self.file?(file_name)
File.file?(file_name)
end
end end
end end

View File

@ -1584,6 +1584,18 @@ class FakeFSTest < Test::Unit::TestCase
assert !FileTest.directory?('/path/to/somedir') assert !FileTest.directory?('/path/to/somedir')
end end
def test_filetest_file_returns_correct_values
path = '/path/to/file.txt'
File.open(path, 'w') { |f| f.write "Yatta!" }
assert FileTest.file?(path)
FileUtils.rm path
assert !FileTest.file?(path)
FileUtils.mkdir_p '/path/to/somedir'
assert !FileTest.file?('/path/to/somedir')
end
def test_pathname_exists_returns_correct_value def test_pathname_exists_returns_correct_value
FileUtils.touch "foo" FileUtils.touch "foo"
assert Pathname.new("foo").exist? assert Pathname.new("foo").exist?