spec/as_hash_spec.rb in mostash-0.0.3 vs spec/as_hash_spec.rb in mostash-0.0.4
- old
+ new
@@ -14,9 +14,24 @@
mo.to_hash.should == { :foo => 'bar', :nested => { :hello => 'world' } }
end
end
+ context 'initialization' do
+ it "should support initialzation from hash with default value" do
+ mo = Mostash.new(Hash.new(123))
+
+ mo.doesnt_exist.should == 123
+ end
+
+ it "should support initialization from hash with block for deafult" do
+ h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
+ mo = Mostash.new h
+
+ mo.doesnt_exist.should == "Go Fish: doesnt_exist"
+ end
+ end
+
context 'hash functions' do
it "should respond to empty?" do
mo = Mostash.new
mo.empty?.should == true