cp_r should also raise an error when it cannot find the source file.
This commit is contained in:
parent
35c2da972b
commit
2a0eba7933
@ -25,6 +25,10 @@ module FakeFS
|
|||||||
def cp_r(src, dest)
|
def cp_r(src, dest)
|
||||||
if dir = FileSystem.find(src)
|
if dir = FileSystem.find(src)
|
||||||
FileSystem.add(dest, dir.entry.clone)
|
FileSystem.add(dest, dir.entry.clone)
|
||||||
|
else
|
||||||
|
# This error sucks, but it conforms to the original Ruby
|
||||||
|
# method.
|
||||||
|
raise "unknown file type: #{src}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -278,4 +278,12 @@ class FakeFSTest < Test::Unit::TestCase
|
|||||||
File.open('baz', 'w') {|f| f.write 'quux' }
|
File.open('baz', 'w') {|f| f.write 'quux' }
|
||||||
assert_equal 'bar', File.open('foo'){|f| f.read }
|
assert_equal 'bar', File.open('foo'){|f| f.read }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_cp_r_should_raise_error_on_missing_file
|
||||||
|
# Yes, this error sucks, but it conforms to the original Ruby
|
||||||
|
# method.
|
||||||
|
assert_raise(RuntimeError) do
|
||||||
|
FileUtils.cp_r 'blafgag', 'foo'
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user