Created
April 10, 2022 22:37
-
-
Save maxcal/2d70b9a8ed088bd731404ec26d74851b to your computer and use it in GitHub Desktop.
Class attributes bug?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_support/all' | |
require 'minitest/autorun' | |
class A | |
class_attribute :x, default: {} | |
end | |
class B < A | |
end | |
class C < A | |
end | |
C.x[:y] = 1 | |
class ClassAttributesBugTest < Minitest::Test | |
def test_subclasses_get_own_hash | |
refute_equal(B.x.object_id, C.x.object_id) | |
end | |
def test_modifying_classes | |
refute_equal(B.x[:y], 1) | |
end | |
def test_modifying_classes_effects_parent | |
refute_equal(A.x[:y], 1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
All three tests are failing.