diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 7f2381d..d301bd5 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -32,6 +32,8 @@ module FakeFS if target = FileSystem.find(src) FileSystem.add(dest, target.entry) FileSystem.delete(src) + else + raise Errno::ENOENT, src end end diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 7d5d427..6901264 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -259,4 +259,10 @@ class FakeFSTest < Test::Unit::TestCase r = File.open('foo','w'){|f| f.write 'bar'; f.flush } assert_equal 'foo', r.path end + + def test_mv_should_raise_error_on_missing_file + assert_raise(Errno::ENOENT) do + FileUtils.mv 'blafgag', 'foo' + end + end end