diff --git a/lib/fakefs.rb b/lib/fakefs.rb index a115331..7f2381d 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -129,6 +129,8 @@ module FakeFS @file.content += content end alias_method :print, :write + + def flush; self; end end class Dir diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 51b0d8c..7d5d427 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -254,4 +254,9 @@ class FakeFSTest < Test::Unit::TestCase File.open('foo','w'){|f| f.write 'bar' } assert_equal 'bar', File.open('foo'){|f| f.read } end + + def test_flush_exists_on_file + r = File.open('foo','w'){|f| f.write 'bar'; f.flush } + assert_equal 'foo', r.path + end end