Sha256: 942dc3690f2755dcd42301b9368ea4ddef46feb5c3c14cea2135f0549a49cd0f

Contents?: true

Size: 864 Bytes

Versions: 65

Compression:

Stored size: 864 Bytes

Contents

require "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

65 entries across 65 versions & 1 rubygems

Version Path
sproutcore-1.11.0 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.11.0.rc3 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.11.0.rc2 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.11.0.rc1 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.10.3.1 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.10.2 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.10.1 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.10.0 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.10.0.rc.3 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.10.0.rc.2 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.10.0.rc.1 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.9.2 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.9.1 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.9.0 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.8.2.1 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.8.1 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.8.0 spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.7.1.beta-java spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.7.1.beta spec/lib/models/hash_struct/method_missing.rb
sproutcore-1.6.0.1-java spec/lib/models/hash_struct/method_missing.rb