diff options
author | Paul Kunysch <kunysch@me.com> | 2013-01-06 21:58:46 +0100 |
---|---|---|
committer | Paul Kunysch <kunysch@me.com> | 2013-01-06 21:58:46 +0100 |
commit | dc9190ec2dc3db43aa991bf6d6db9ebe41c2432f (patch) | |
tree | d77772f222356d5b26cfad7331abdfb0fb517853 | |
parent | 6a3ac11a78827f21054b2ec6492683d5b4db20e7 (diff) | |
download | psych-dc9190ec2dc3db43aa991bf6d6db9ebe41c2432f.zip |
Testing custom character-based class.
-rw-r--r-- | test/psych/test_string.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index 77aefc6..e3fa8d6 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -9,6 +9,12 @@ module Psych attr_accessor :val end + class Z < String + def initialize + force_encoding Encoding::US_ASCII + end + end + def test_another_subclass_with_attributes y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1} assert_equal "foo", y @@ -28,6 +34,12 @@ module Psych assert_equal X, x.class end + def test_empty_character_subclass + assert_match "!ruby/string:#{Z}", Psych.dump(Z.new) + x = Psych.load Psych.dump Z.new + assert_equal Z, x.class + end + def test_subclass_with_attributes y = Psych.load Psych.dump Y.new.tap {|y| y.val = 1} assert_equal Y, y.class |