diff options
Diffstat (limited to 'activesupport/test/class_inheritable_attributes_test.rb')
-rw-r--r-- | activesupport/test/class_inheritable_attributes_test.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/activesupport/test/class_inheritable_attributes_test.rb b/activesupport/test/class_inheritable_attributes_test.rb index 54e533e964..048b86135c 100644 --- a/activesupport/test/class_inheritable_attributes_test.rb +++ b/activesupport/test/class_inheritable_attributes_test.rb @@ -137,4 +137,34 @@ class ClassInheritableAttributesTest < Test::Unit::TestCase assert_equal 'b', @klass.b assert_equal 'B', @sub.b end + + def test_array_inheritance + @klass.class_inheritable_accessor :a + @klass.a = [] + + @sub = eval("class SubbyArray < @klass; end; SubbyArray") + + assert_equal [], @klass.a + assert_equal [], @sub.a + + @sub.a << :first + + assert_equal [:first], @sub.a + assert_equal [], @klass.a + end + + def test_array_inheritance + @klass.class_inheritable_accessor :a + @klass.a = {} + + @sub = eval("class SubbyHash < @klass; end; SubbyHash") + + assert_equal Hash.new, @klass.a + assert_equal Hash.new, @sub.a + + @sub.a[:first] = :first + + assert_equal 1, @sub.a.keys.size + assert_equal 0, @klass.a.keys.size + end end |