Sha256: c214e36e2343e149766bf07288606a55e3578596b09631b0bb4582d7d545dc73
Contents?: true
Size: 708 Bytes
Versions: 5
Compression:
Stored size: 708 Bytes
Contents
require "#{File.dirname __FILE__}/helper" require "ruby_ext/deep_clone" describe 'deep_clone' do it "basic" do hash, array = {}, ['value'] hash['key'] = array hash2 = hash.deep_clone array2 = hash2['key'] hash2.should == hash hash2.object_id.should_not == hash.object_id array2.should == array array2.object_id.should_not == array.object_id end it do class Metadata attr_accessor :registry def initialize @registry = {} end end m = Metadata.new m.registry[:a] = 1 m2 = m.deep_clone m2.registry.should include(:a) m2.registry[:b] = 2 m.registry.should == {:a => 1} end end
Version data entries
5 entries across 5 versions & 2 rubygems