From b5e7359eacc5a432892e2deda02d296867d89d3a Mon Sep 17 00:00:00 2001 From: Jeff Hodges Date: Sat, 30 May 2009 23:24:29 -0700 Subject: [PATCH] fixing FileUtils.mv --- lib/fakefs.rb | 2 +- test/fakefs_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/fakefs.rb b/lib/fakefs.rb index d301bd5..306ed40 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -30,7 +30,7 @@ module FakeFS def mv(src, dest) if target = FileSystem.find(src) - FileSystem.add(dest, target.entry) + FileSystem.add(dest, target.entry.clone) FileSystem.delete(src) else raise Errno::ENOENT, src diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 6901264..48e84df 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -265,4 +265,10 @@ class FakeFSTest < Test::Unit::TestCase FileUtils.mv 'blafgag', 'foo' end end + + def test_mv_actually_works + File.open('foo', 'w') {|f| f.write 'bar' } + FileUtils.mv 'foo', 'baz' + assert_equal 'bar', File.open('baz'){|f| f.read } + end end