diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 8e1cefc..279fb5c 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -217,10 +217,6 @@ module FakeFS super(@file.content, mode) end - def close - @open = false - end - def exists? true end diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index a5a0558..2d6babc 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -330,6 +330,16 @@ class FakeFSTest < Test::Unit::TestCase end end + def test_File_close_disallows_further_writes + path = '/path/to/file.txt' + file = File.open(path, 'w') + file.write 'Yada' + file.close + assert_raise IOError do + file << "foo" + end + end + def test_can_read_from_file_objects path = '/path/to/file.txt' File.open(path, 'w') do |f|