Sha256: 815161d2562358b249ddae57e3974dc5bcd547e11a20953e2238707530700282
Contents?: true
Size: 1.65 KB
Versions: 1
Compression:
Stored size: 1.65 KB
Contents
require 'spec_helper' describe 'MoStash as Hash' do it "should support merge when single level" do mo = MoStash.new :foo => 'bar', :hello => 'world' new_mo = mo.merge( :hello => 'tester' ) new_mo[:foo].should == 'bar' new_mo[:hello].should == 'tester' end it "should support merge of single level when multi leveled" do mo = MoStash.new( { :foo => 'bar', :nested => { :hello => 'world' }} ) new_mo = mo.merge( :foo => 'baz' ) new_mo[:foo].should == 'baz' new_mo[:nested][:hello].should == 'world' end it "should support merge of multi levels when is multi leveled" do mo = MoStash.new( { :foo => 'bar', :nested => { :hello => 'world' }} ) new_mo = mo.merge( :nested => { :hello => 'tester' } ) new_mo[:foo].should == 'bar' new_mo[:nested][:hello].should == 'tester' new_mo[:nested].class.should == MoStash end it "should support merge!" do mo = MoStash.new( :foo => 'bar' ) mo.merge!( :foo => 'baz' ) mo.foo.should == 'baz' end it "should support multi level merge!" do mo = MoStash.new( { :foo => 'bar', :nested => { :hello => 'world' }} ) mo.merge!( :nested => { :hello => 'tester' } ) mo[:foo].should == 'bar' mo[:nested][:hello].should == 'tester' mo[:nested].class.should == MoStash end it "should be able to return a hash for single level" do mo = MoStash.new( :foo => 'bar' ) mo.to_hash.should == { :foo => 'bar' } end it "should be able to return a hash for multi level" do mo = MoStash.new( :foo => 'bar', :nested => { :hello => 'world' } ) mo.to_hash.should == { :foo => 'bar', :nested => { :hello => 'world' } } end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mostash-0.0.2 | spec/as_hash_spec.rb |