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 end
def check_file_existence! def check_file_existence!
unless @file raise Errno::ENOENT, @path unless @file
raise Errno::ENOENT, "No such file or directory - #{@file}"
end
end end
def file_creation_mode? def file_creation_mode?

View File

@ -84,13 +84,14 @@ class FakeFileTest < Test::Unit::TestCase
assert_equal "bar", @file.content assert_equal "bar", @file.content
end 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 begin
FakeFS::File.new "/some/non/existing/file" FakeFS::File.new path
msg = nil msg = nil
rescue Errno::ENOENT => e rescue Errno::ENOENT => e
msg = e.message msg = e.message
end 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
end end