Fixes File#check_file_existence! always prints empty path. Closes #34

This commit is contained in:
Lars Gierth 2010-12-27 19:01:38 +01:00 committed by Scott Taylor
parent 124a138254
commit 68c958df0d
2 changed files with 5 additions and 6 deletions

View File

@ -379,9 +379,7 @@ module FakeFS
end
def check_file_existence!
unless @file
raise Errno::ENOENT, "No such file or directory - #{@file}"
end
raise Errno::ENOENT, @path unless @file
end
def file_creation_mode?

View File

@ -84,13 +84,14 @@ class FakeFileTest < Test::Unit::TestCase
assert_equal "bar", @file.content
end
def test_gh_34_doesnt_print_path_of_nonexisting_file
def test_raises_an_error_with_the_correct_path
path = "/some/non/existing/file"
begin
FakeFS::File.new "/some/non/existing/file"
FakeFS::File.new path
msg = nil
rescue Errno::ENOENT => e
msg = e.message
end
assert_match /^No such file or directory - No such file or directory - $/, msg
assert_equal "No such file or directory - #{path}", msg
end
end