Sha256: d3539c47b54579cec7fadbaa7664bdef6cba4541c82c0ede810d783b3459acec
Contents?: true
Size: 887 Bytes
Versions: 2
Compression:
Stored size: 887 Bytes
Contents
require File.dirname(__FILE__) + '/spec_helper' describe Hash do before(:each) do @h = { :foo => 1, :bar => 2, :baz => 3 } @nh = { :foo => { :bar => 2 }, :baz => { :biz => 4 } } end it 'should respond to all the new methods' do Hash.new.should respond_to(*%w(nested_find deep_merge!)) end it 'should deep merge' do a = { :foo => 1, :bar => { :baz => 10, :biz => { :hello => :world }}} b = { :pickles => true, :sandwich => { :ham => 2, :bread => { :grains => :whole }}} result = { :foo => 1, :pickles => true, :sandwich => { :ham => 2, :bread => { :grains => :whole }}, :bar => { :baz => 10, :biz => { :hello => :world }}} a.deep_merge!(b) a.should == result end it 'should find nested things' do @nh.nested_find(:baz,:biz).should == 4 @nh.nested_find(:foo,:bar).should == 2 @nh.nested_find(:foo,:biz).should be_nil end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
darkhelmet-darkext-0.12.0 | spec/hash_spec.rb |
darkext-0.12.0 | spec/hash_spec.rb |