Sha256: 96222be439cd9efcd7eb8df502b4b867e9a0d4b49d70e066f092b8df092befb7
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
require 'amrita2' context "Hash Delegator" do include Amrita2 specify "delegate to Hash" do h = { :one => 1 } c = Amrita2::HashDelegator.new(h) do { :two=>2, } end c.one.should == 1 c.two.should == 2 c[:one].should == 1 c[:two].should == 2 c.three.should be_nil c[:three].should be_nil end specify "delegate to Struct" do s = Struct.new(:one).new(1) c = Amrita2::HashDelegator.new(s) do { :two=>2, } end c.one.should == 1 c.two.should == 2 c[:one].should == 1 c[:two].should == 2 proc { c.three }.should raise_error c[:three].should be_nil end specify "double delegate to Struct" do s = Struct.new(:one).new(1) c1 = Amrita2::HashDelegator.new(s) do { :two=>2, } end c2 = Amrita2::HashDelegator.new(c1) do { :three=>3, } end c2.one.should == 1 c2.two.should == 2 c2[:one].should == 1 c2[:two].should == 2 c2.three.should == 3 c2[:three].should == 3 proc { c2.four }.should raise_error c2[:four].should be_nil end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
amrita2-2.0.0 | specs/impl/hash_delegator.rb |
amrita2-2.0.1 | specs/impl/hash_delegator.rb |
amrita2-2.0.2 | specs/impl/hash_delegator.rb |