spec/rash_spec.rb in rash-0.3.2 vs spec/rash_spec.rb in rash-0.4.0

- old
+ new

@@ -55,18 +55,57 @@ subject.nested.nestedOne = "once" subject.nested.nested_one.should == "once" end it "should merge well with a Mash" do + merged = subject.merge Hashie::Mash.new( + :nested => {:fourTimes => "a charm"}, + :nested3 => {:helloWorld => "hi"} + ) + + merged.nested.four_times.should == "a charm" + merged.nested.fourTimes.should == "a charm" + merged.nested3.should be_a(Hashie::Rash) + merged.nested3.hello_world.should == "hi" + merged.nested3.helloWorld.should == "hi" + merged[:nested3][:helloWorld].should == "hi" + end + + it "should update well with a Mash" do subject.update Hashie::Mash.new( :nested => {:fourTimes => "a charm"}, :nested3 => {:helloWorld => "hi"} ) subject.nested.four_times.should == "a charm" subject.nested.fourTimes.should == "a charm" + subject.nested3.should be_a(Hashie::Rash) subject.nested3.hello_world.should == "hi" subject.nested3.helloWorld.should == "hi" + subject[:nested3][:helloWorld].should == "hi" + end + + it "should merge well with a Hash" do + merged = subject.merge({ + :nested => {:fourTimes => "work like a charm"}, + :nested3 => {:helloWorld => "hi"} + }) + + merged.nested.four_times.should == "work like a charm" + merged.nested.fourTimes.should == "work like a charm" + merged.nested3.should be_a(Hashie::Rash) + merged.nested3.hello_world.should == "hi" + merged.nested3.helloWorld.should == "hi" + merged[:nested3][:helloWorld].should == "hi" + end + + it "should handle assigning a new Hash and convert it to a rash" do + subject.nested3 = {:helloWorld => "hi"} + + subject.nested3.should be_a(Hashie::Rash) + subject.nested3.hello_world.should == "hi" + subject.nested3.helloWorld.should == "hi" + subject[:nested3][:helloWorld].should == "hi" end it "should allow initializing reader" do subject.nested3!.helloWorld = "hi" subject.nested3.hello_world.should == "hi"