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

Version Path
sproutit-sproutcore-1.0.0.20090407205609 spec/lib/models/hash_struct/method_missing.rb
sproutit-sproutcore-1.0.0.20090408130025 spec/lib/models/hash_struct/method_missing.rb
sproutit-sproutcore-1.0.0.20090416161445 spec/lib/models/hash_struct/method_missing.rb
sproutit-sproutcore-1.0.20090721145236 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1046 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1043 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1042 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1037 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1035 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1031 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1030 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1029 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1027 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1028 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1026 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1025 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1024 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1009 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1008 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.0.1003 spec/lib/models/hash_struct/method_missing.rb