diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 7b8eccf..2b73439 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -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 diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index ca96d82..1bc2ed2 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -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