diff --git a/lib/fakefs/file.rb b/lib/fakefs/file.rb index 6836c8b..55e727b 100644 --- a/lib/fakefs/file.rb +++ b/lib/fakefs/file.rb @@ -242,7 +242,7 @@ module FakeFS end def to_io - raise NotImplementedError + self end def write_nonblock(string) diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index cb396d6..9e25aa9 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -364,6 +364,11 @@ class FakeFSTest < Test::Unit::TestCase assert File.file?(path) end + def test_File_io_returns_self + f = File.open("/foo", "w") + assert_equal f, f.to_io + end + def test_knows_symlink_files_are_files path = '/path/to/file.txt' File.open(path, 'w') do |f|