Sha256: 7cbb825c79f33f4b943a0587584048fa1976d096977759fc7cc1d60c571e1a8f

Contents?: true

Size: 688 Bytes

Versions: 3

Compression:

Stored size: 688 Bytes

Contents

require "spec_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

3 entries across 3 versions & 1 rubygems

Version Path
ruby_ext-0.4.11 spec/deep_clone_spec.rb
ruby_ext-0.4.10 spec/deep_clone_spec.rb
ruby_ext-0.4.9 spec/deep_clone_spec.rb