Skip to content

Instantly share code, notes, and snippets.

@jrafanie
Created April 26, 2012 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrafanie/2501904 to your computer and use it in GitHub Desktop.
Save jrafanie/2501904 to your computer and use it in GitHub Desktop.
Psych subclasses of String lose string value
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