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