Created
April 26, 2012 18:49
-
-
Save jrafanie/2501904 to your computer and use it in GitHub Desktop.
Psych subclasses of String lose string value
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
diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb | |
index 9eedbb4..5058676 100644 | |
--- a/test/psych/test_array.rb | |
+++ b/test/psych/test_array.rb | |
@@ -25,7 +25,11 @@ module Psych | |
end | |
def test_subclass_with_attributes | |
- y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1} | |
+ y = Y.new.tap {|y| y.val = 1} | |
+ y << "foo" << "bar" | |
+ y = Psych.load Psych.dump y | |
+ | |
+ assert_equal %w{foo bar}, y | |
assert_equal Y, y.class | |
assert_equal 1, y.val | |
end | |
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb | |
index c7d5c60..ade408d 100644 | |
--- a/test/psych/test_string.rb | |
+++ b/test/psych/test_string.rb | |
@@ -22,7 +22,8 @@ module Psych | |
end | |
def test_subclass_with_attributes | |
- y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1} | |
+ y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1} | |
+ assert_equal "foo", y | |
assert_equal Y, y.class | |
assert_equal 1, y.val | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment