Sha256: b11d9a0ae2ed7a41154cbcbe40d27faa7cb1b169d61e7f0ed58b4ed866cf2b10

Contents?: true

Size: 823 Bytes

Versions: 28

Compression:

Stored size: 823 Bytes

Contents

require "#{File.dirname(__FILE__)}/../../test_helper"

class ModTestObject
  default_attr_reader :a, ["b"]
  default_attr_reader :hsh, {}
end

class ChildModTestObject < ModTestObject
end

class ModuleTest < Test::Unit::TestCase
  
  context "default accessors" do
    setup do
      @inst = ModTestObject.new
    end

    should "set the default to an array" do
      assert_equal Array, @inst.a.class
    end
    
    should "put an object in the a variable without it being defined" do
      @inst.a << "hi"
      assert_equal ["b", "hi"], @inst.a
    end
    
    should "merge with the default hash" do
      @inst.hsh.merge!(:big => "people")
      assert_equal({:big => "people"}, @inst.hsh)
    end
    
    should "carry to the child" do
      assert_equal ["b"], ChildModTestObject.new.a
    end
    
  end
  
end

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
auser-poolparty-1.3.0 test/lib/core/module_test.rb
auser-poolparty-1.3.1 test/lib/core/module_test.rb
auser-poolparty-1.3.10 test/lib/core/module_test.rb
auser-poolparty-1.3.11 test/lib/core/module_test.rb
auser-poolparty-1.3.12 test/lib/core/module_test.rb
auser-poolparty-1.3.13 test/lib/core/module_test.rb
auser-poolparty-1.3.14 test/lib/core/module_test.rb
auser-poolparty-1.3.15 test/lib/core/module_test.rb
auser-poolparty-1.3.16 test/lib/core/module_test.rb
auser-poolparty-1.3.17 test/lib/core/module_test.rb
auser-poolparty-1.3.2 test/lib/core/module_test.rb
auser-poolparty-1.3.3 test/lib/core/module_test.rb
auser-poolparty-1.3.4 test/lib/core/module_test.rb
auser-poolparty-1.3.5 test/lib/core/module_test.rb
auser-poolparty-1.3.6 test/lib/core/module_test.rb
auser-poolparty-1.3.7 test/lib/core/module_test.rb
auser-poolparty-1.3.8 test/lib/core/module_test.rb
fairchild-poolparty-1.3.17 test/lib/core/module_test.rb
fairchild-poolparty-1.3.5 test/lib/core/module_test.rb
poolparty-1.3.15 test/lib/core/module_test.rb