Sha256: f3d94c65916642b928bf2f5a494f33316f44402f64eeba1461a406605f640c40
Contents?: true
Size: 1.46 KB
Versions: 24
Compression:
Stored size: 1.46 KB
Contents
require 'awestruct/astruct' require 'awestruct/page' describe Awestruct::AStruct do it "should initialize from hash provided in constructor" do s = Awestruct::AStruct.new( :foo=>'bar', 'taco'=>'tasty' ) s[:foo].should == 'bar' s['taco'].should == 'tasty' end it "should allow access to members through indifferent hash access" do s = Awestruct::AStruct.new( :foo=>'bar', 'taco'=>'tasty' ) s['foo'].should == 'bar' s[:foo].should == 'bar' s['taco'].should == 'tasty' s[:taco].should == 'tasty' end it "should allow method access to members" do s = Awestruct::AStruct.new( :foo=>'bar', 'taco'=>'tasty' ) s.foo.should == 'bar' s.taco.should == 'tasty' end it "should cascade AStructs to inner array members" do s = Awestruct::AStruct.new( :foo=>[ { 'taco'=>'tasty' } ] ) s.foo.first.taco.should == 'tasty' end it "should preserve the actual array instance holding any inner structs" do inner_hash = { 'taco'=>'tasty' } array = [ inner_hash ] s = Awestruct::AStruct.new( :foo=>array ) s.foo.first.taco.should == 'tasty' s.foo.object_id.should == array.object_id end it "should cascade AStruct to inner hash value structs" do s = Awestruct::AStruct.new( :foo=>{ 'taco'=>'tasty' } ) s.foo.taco.should == 'tasty' end it "should allow any method to be called, resulting in nil" do s = Awestruct::AStruct.new( :foo=>'bar' ) s.foo.should == 'bar' s.taco.should be_nil end end
Version data entries
24 entries across 24 versions & 1 rubygems
Version | Path |
---|---|
awestruct-0.5.1 | spec/astruct_spec.rb |
awestruct-0.5.1a | spec/astruct_spec.rb |
awestruct-0.5.0 | spec/astruct_spec.rb |
awestruct-0.5.0.cr | spec/astruct_spec.rb |