cp_r should also raise an error when it cannot find the source file.

This commit is contained in:
Jeff Hodges 2009-05-30 23:40:45 -07:00
parent 35c2da972b
commit 2a0eba7933
2 changed files with 12 additions and 0 deletions

View File

@ -25,6 +25,10 @@ module FakeFS
def cp_r(src, dest)
if dir = FileSystem.find(src)
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

View File

@ -278,4 +278,12 @@ class FakeFSTest < Test::Unit::TestCase
File.open('baz', 'w') {|f| f.write 'quux' }
assert_equal 'bar', File.open('foo'){|f| f.read }
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