Skip to content

Commit

Permalink
Improved Fake::File inspect method to output more like a real File. A…
Browse files Browse the repository at this point in the history
…dded File.open test
  • Loading branch information
davidmiani committed Dec 12, 2009
1 parent fe00367 commit 931f89a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/fakefs/file.rb
Expand Up @@ -268,6 +268,12 @@ def to_io
self
end

def inspect
# TODO should be a test to see if file is closed before
# adding (closed) to output
"#<File:#{@path.gsub("//", "/")} (closed)>"
end

def write_nonblock(string)
raise NotImplementedError
end
Expand Down
15 changes: 15 additions & 0 deletions test/passing_fs_tests.rb
Expand Up @@ -47,6 +47,21 @@ def test_fileutils_copy
end
end

def test_file_open
compare_with_real do
check_value File.open(mp("test.txt"), "w") { |f| f.write("hello") }
check_filesystem
Dir.mkdir mp("Home")

file = File.open(mp("Home/comics.txt"), "a") do |f|
f << "Cat and Girl: http://catandgirl.com/\n"
end

check_value file.inspect
check_filesystem
end
end

end


0 comments on commit 931f89a

Please sign in to comment.