cp_r given a src ending in '/.' now copies over the contents of the
src dir.
This commit is contained in:
parent
da576d4208
commit
c0be5bd8f2
@ -38,8 +38,14 @@ module FakeFS
|
||||
raise Errno::ENOENT, dest
|
||||
end
|
||||
|
||||
# This last bit is a total abuse and should be thought hard
|
||||
# about and cleaned up.
|
||||
if new_dir
|
||||
if src[-2..-1] == '/.'
|
||||
dir.values.each{|f| new_dir[f.name] = f }
|
||||
else
|
||||
new_dir[dir.name] = dir.entry.clone
|
||||
end
|
||||
else
|
||||
FileSystem.add(dest, dir.entry.clone)
|
||||
end
|
||||
|
@ -354,6 +354,15 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
RealFile.unlink(here('foo')) if RealFile.exists?(here('foo'))
|
||||
end
|
||||
|
||||
def test_putting_a_dot_at_end_copies_the_contents
|
||||
FileUtils.mkdir_p 'subdir'
|
||||
Dir.chdir('subdir'){ File.open('foo', 'w'){|f| f.write 'footext' } }
|
||||
|
||||
FileUtils.mkdir_p 'newdir'
|
||||
FileUtils.cp_r 'subdir/.', 'newdir'
|
||||
assert_equal 'footext', File.open('newdir/foo'){|f| f.read }
|
||||
end
|
||||
|
||||
def test_file_can_read_from_symlinks
|
||||
File.open('first', 'w'){|f| f.write '1'}
|
||||
FileUtils.ln_s 'first', 'one'
|
||||
|
Loading…
Reference in New Issue
Block a user