Sha256: 67528798eaab2b272b848636276c977057bf50e332d8169639b9597d41adc511
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
require 'spec_helper' describe MoStash do it "should act like basic OpenStruct" do mo = MoStash.new mo.foo = "bar" mo.foo.should == "bar" end it "should allow basic Hash methods" do mo = MoStash.new mo.foo = "bar" mo[:baz] = "foo" mo[:foo].should == "bar" mo.baz.should == "foo" end it "should be initializable via a Hash" do mo = MoStash.new(:foo => "bar") mo.foo.should == "bar" end it "should be initializable via nested Hash" do h = {:foo => {:bar => "baz"}, :oh => "hai"} mo = MoStash.new h mo.foo.bar.should == "baz" mo.oh.should == "hai" end it "should allow values to be arrays" do mo = MoStash.new mo.foo = ['hello'] mo.foo.first.should == "hello" end it "should automatically make a hash a MoStash" do mo = MoStash.new mo.foo = {:bar => 'baz'} mo.foo.bar.should == 'baz' end it "should correctly handle an array of hashes" do mo = MoStash.new mo.foo = [{:hey => 'you'}, {:oh => 'hai'}] mo.foo[1].oh.should == 'hai' end it "should create method when new method called" do mo = Mostash.new mo.foo = "bar" mo.methods.should include(:foo) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mostash-0.0.4 | spec/mostash_spec.rb |
mostash-0.0.3 | spec/mostash_spec.rb |