Sha256: 31bf580a3a941737840aa155beeedc034d34f8f92cd06231140e79f11ae363f5

Contents?: true

Size: 1.69 KB

Versions: 2

Compression:

Stored size: 1.69 KB

Contents

$:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
$:.unshift File.join(File.dirname(__FILE__), '..', '..', '..', 'og', 'lib')

require 'test/unit'
require 'glue/attribute'

module Mixin
  attr_accessor :date
  ann self, :dummy => [123]
end

class MixedOnly
  include Mixin
  ann.self.dummy! << 5
  ann.self.dummy! << 3 
end

class MixedOnly2
  include Mixin
end

class MixedWithProp
  include Mixin

  attr_accessor :dummy
end

class Pure
  attr_accessor :dummy
end

class Empty
end

class Base
  attr_accessor :date
  ann self, :dummy => [123]
end

class Child1 < Base
  ann.self.dummy!.first << 5
  ann.self.dummy!.first << 3 
end

class Child2 < Base
end

# Tests auto management.
class TC_MixinsTest < ::Test::Unit::TestCase
  def test_the_unmanaged
    assert( Empty.respond_to?( :__props ) == false )
    assert_respond_to( Pure.new, :dummy )
  end

  def test_manage_entities
    assert_respond_to( Pure, :serializable_attributes )
    assert_respond_to( Pure.new, :dummy )
  end

  def test_managing_mixedonly_classes
    assert_respond_to( MixedOnly.new, :date )
  end

  def test_managing_mixins
    assert_respond_to( Mixin, :serializable_attributes )
  end

  def test_managing_mixed_classes
    obj = MixedWithProp.new
    assert( obj.respond_to?( :date ) )
    assert( obj.respond_to?( :dummy ) )
  end

  def test_crosspolination
    assert_equal 3, MixedOnly.ann.self[:dummy].size  
# FIXME:
#   assert_equal 1, MixedOnly2.ann.self[:dummy].size  
#   assert_equal 1, Mixin.ann.self[:dummy].size  
=begin
    gmosx: THINK!
    assert_equal 3, Child1.__meta[:dummy].first.size  
    assert_equal 1, Child2.__meta[:dummy].first.size  
    assert_equal 1, Base.__meta[:dummy].first.size  
=end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
glue-0.41.0 test/glue/tc_attribute_mixins.rb
glue-0.40.0 test/glue/tc_attribute_mixins.rb