FileSystem.clone now works when cloning regular files.

This commit is contained in:
Jeff Hodges 2009-05-31 02:24:33 -07:00
parent 2a0eba7933
commit 4f6259d180
2 changed files with 11 additions and 2 deletions

View File

@ -215,8 +215,8 @@ module FakeFS
files.each do |f|
if RealFile.file?(f)
FileUtils.mkdir_p(File.dirname(f))
File.open(f, 'w') do |f|
f.puts RealFile.read(f)
File.open(f, 'w') do |g|
g.print RealFile.open(f){|h| h.read }
end
elsif RealFile.directory?(f)
FileUtils.mkdir_p(f)

View File

@ -286,4 +286,13 @@ class FakeFSTest < Test::Unit::TestCase
FileUtils.cp_r 'blafgag', 'foo'
end
end
def test_clone_clones_normal_files
def here(fname); File.expand_path(File.dirname(__FILE__)+'/'+fname); end
RealFile.open(here('foo'), 'w'){|f| f.write 'bar' }
FileSystem.clone(here('foo'))
assert_equal 'bar', File.open('foo'){|f| f.read }
ensure
RealFile.unlink(here('foo')) if RealFile.exists?(here('foo'))
end
end