Sha256: bda7e62fe87f0bc7063e7c8f4bffd9ac9c52e3162588ba4984f599696921e90f
Contents?: true
Size: 927 Bytes
Versions: 20
Compression:
Stored size: 927 Bytes
Contents
require File.join(File.dirname(__FILE__), %w[.. .. .. spec_helper]) describe SC::HashStruct, 'method_missing' do before do hash = SC::HashStruct.new :foo => :foo end it "should map hash.foo => hash[:foo]" do hash.foo.should eql(:foo) end it "should map hash.bar = :foo => hash[:bar] = :foo" do hash[:bar].should eql(nil) hash.bar = :foo hash.bar.should eql(:foo) hash[:bar].should eql(:foo) end it "should map hash.foo? => !!hash[:foo]" do hash.foo?.should eql(true) hash.bar = 1 hash.bar?.should eql(true) hash.bar = 0 hash.bar?.should eql(0) end it "should map hash.undefined_prop? => false" do hash.undefined_prop?.should eql(false) # not defined... end it "should map hash.bar? = :foo to hash[:bar] = !!:foo" do hash.bar? = :foo hash[:bar].should eql(true) hash.bar? = 0 hash[:bar].should eql(false) end end
Version data entries
20 entries across 20 versions & 2 rubygems