do a deep copy of the hash

This commit is contained in:
Chris Wanstrath 2009-07-19 14:23:02 -07:00
parent 6a540e6841
commit eb634265e6
2 changed files with 5 additions and 3 deletions

View File

@ -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

View File

@ -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/*']