Sha256: 9a1d9dba088a77cf137544998d8c7ad778a6edc8abcbd5c0d20830ebe0fc33e7
Contents?: true
Size: 1.93 KB
Versions: 1
Compression:
Stored size: 1.93 KB
Contents
require 'deep_dive' class FooBase include DeepDive exclude :c end class Foo < FooBase attr_accessor :a, :b, :c, :changeme end class Bar < FooBase attr_accessor :a, :b, :c, :changeme end class FooBar < FooBase attr_accessor :a, :b, :c, :changeme, :dontcopy, :arr, :hsh, :nonddob exclude :dontcopy end describe DeepDive do before(:each) do @foo = Foo.new @bar = Bar.new @foobar = FooBar.new @foobar.arr = [@foo, @bar, @foobar, "Just a string"] @foobar.hsh = {foo: @foo, bar: @bar, foobar: @foobar, nonddob: "just a string"} @foo.a = 'foo just around' @bar.a = 'bar hanging around' @foo.b = @bar @bar.b = @foo @foo.c = @bar.c = @foobar.c = @foobar @foo.changeme = @bar.changeme = @foobar.changeme = "initial" end context 'clone' do it 'simple' do cfoo = @foo.dclone cfoo.should_not == nil cfoo.should_not == @foo @foo.b.changeme = 'changed' @foobar.changeme = 'also changed' cfoo.c.changeme.should == @foobar.changeme cfoo.b.changeme.should_not == @foo.b.changeme end it 'exclusion' do @foobar.dontcopy = @bar cfoobar = @foobar.dclone cfoobar.dontcopy.should == @foobar.dontcopy @foo.a = @bar cfoo = @foo.dclone cfoo.a.should_not == @foo.a end end context 'dup' do it 'simple' do cfoo = @foo.ddup cfoo.should_not == nil end it 'deep' end context 'enumerables' do it 'makes copies of the arrayed objects' do cfb = @foobar.dclone cfb.arr.size.should > 0 (0 ... cfb.arr.size).each do |i| cfb.arr[i].should_not be_nil if @foobar.arr[i].respond_to? :_replicate cfb.arr[i].should_not == @foobar.arr[i] end end end it 'makes copies of the hashed objects' do cfb = @foobar.dclone cfb.hsh.size.should > 0 cfb.hsh.each do |k, o| cfb.hsh[k].should_not == @foobar.hsh[k] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
deep_dive-0.0.4 | spec/lib/deep_dive/deep_dive_spec.rb |