From 45b0e2828f6465831d378ebdaef514bb1e4521f5 Mon Sep 17 00:00:00 2001 From: Jeff Hodges Date: Sat, 30 May 2009 21:22:57 -0700 Subject: [PATCH] adding File#flush --- lib/fakefs.rb | 2 ++ test/fakefs_test.rb | 5 +++++ 2 files changed, 7 insertions(+) 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