1 require File.dirname(__FILE__) + '/../test_helper'
2 require 'inheritable_class_attributes'
4 class InheritableClassAttributesTest < Test::Unit::TestCase
6 include InheritableClassAttributes
8 cattr_inheritable_reader :reader
11 cattr_inheritable_writer :writer
14 cattr_inheritable_accessor :accessor
18 def test_inheritable_reader
19 assert_equal :test, A.reader
22 def test_inheritable_writer
24 assert_equal :changed, A.module_eval(%{@writer})
27 def test_inheritable_accessor
29 assert_equal :changed, A.accessor
33 A.accessor = :unchanged
34 Kernel.module_eval %{ class B < A; end }
36 assert_equal :changed, B.accessor
37 assert_equal :unchanged, A.accessor
40 def test_array_inheritance
42 Kernel.module_eval %{ class C < A; end }
44 assert_equal [1,2,3,4], C.accessor
45 assert_equal [1,2,3], A.accessor