FileSystem.clone now works when cloning regular files.
This commit is contained in:
parent
2a0eba7933
commit
4f6259d180
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user