Fixing cp_r sharing data between files copied

This commit is contained in:
Jeff Hodges 2009-05-30 23:30:50 -07:00
parent b5e7359eac
commit 35c2da972b
2 changed files with 8 additions and 1 deletions

View File

@ -24,7 +24,7 @@ module FakeFS
def cp_r(src, dest)
if dir = FileSystem.find(src)
FileSystem.add(dest, dir.entry)
FileSystem.add(dest, dir.entry.clone)
end
end

View File

@ -271,4 +271,11 @@ class FakeFSTest < Test::Unit::TestCase
FileUtils.mv 'foo', 'baz'
assert_equal 'bar', File.open('baz'){|f| f.read }
end
def test_cp_r_doesnt_tangle_files_together
File.open('foo', 'w') {|f| f.write 'bar' }
FileUtils.cp_r('foo', 'baz')
File.open('baz', 'w') {|f| f.write 'quux' }
assert_equal 'bar', File.open('foo'){|f| f.read }
end
end