parent
b91fddf98b
commit
4e9355dc9e
@ -95,14 +95,16 @@ module FakeFS
|
||||
end
|
||||
|
||||
def mv(src, dest, options={})
|
||||
if target = FileSystem.find(src)
|
||||
d_path = File.directory?(dest) ? File.join(dest, File.basename(src)) : dest
|
||||
FileSystem.add(d_path, target.entry.clone)
|
||||
FileSystem.delete(src)
|
||||
Array(src).each do |path|
|
||||
if target = FileSystem.find(path)
|
||||
dest_path = File.directory?(dest) ? File.join(dest, File.basename(path)) : dest
|
||||
FileSystem.add(dest_path, target.entry.clone)
|
||||
FileSystem.delete(path)
|
||||
else
|
||||
raise Errno::ENOENT, src
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def chown(user, group, list, options={})
|
||||
list = Array(list)
|
||||
|
@ -805,6 +805,15 @@ class FakeFSTest < Test::Unit::TestCase
|
||||
assert File.directory?('destdir')
|
||||
end
|
||||
|
||||
def test_mv_array
|
||||
File.open('foo', 'w') {|f| f.write 'bar' }
|
||||
File.open('baz', 'w') {|f| f.write 'binky' }
|
||||
FileUtils.mkdir_p 'destdir'
|
||||
FileUtils.mv %w(foo baz), 'destdir'
|
||||
assert_equal('bar', File.open('destdir/foo') {|f| f.read })
|
||||
assert_equal('binky', File.open('destdir/baz') {|f| f.read })
|
||||
end
|
||||
|
||||
def test_cp_actually_works
|
||||
File.open('foo', 'w') {|f| f.write 'bar' }
|
||||
FileUtils.cp('foo', 'baz')
|
||||
|
Loading…
Reference in New Issue
Block a user