diff --git a/lib/fakefs.rb b/lib/fakefs.rb index 5d4ae11..1e3c388 100644 --- a/lib/fakefs.rb +++ b/lib/fakefs.rb @@ -387,7 +387,7 @@ module FakeFS end def clone(parent) - clone = super() + clone = Marshal.load(Marshal.dump(self)) clone.each do |key, value| value.parent = parent end diff --git a/test/fakefs_test.rb b/test/fakefs_test.rb index 2389ab5..8d32d63 100644 --- a/test/fakefs_test.rb +++ b/test/fakefs_test.rb @@ -121,7 +121,7 @@ class FakeFSTest < Test::Unit::TestCase file.read end end - + def test_can_read_from_file_objects path = '/path/to/file.txt' File.open(path, 'w') do |f| @@ -197,8 +197,10 @@ class FakeFSTest < Test::Unit::TestCase FileUtils.mkdir_p '/path/bar' File.open('/path/bar/baz', 'w'){|f| f.write 'foo' } + FileUtils.cp_r '/path/bar', '/path/bar2' + assert_equal ['/path'], Dir['/path'] - assert_equal ['/path/bar', '/path/foo', '/path/foobar'], Dir['/path/*'] + assert_equal %w( /path/bar /path/bar2 /path/foo /path/foobar ), Dir['/path/*'] assert_equal ['/path/bar/baz'], Dir['/path/bar/*']