summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-01-26 18:03:53 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2010-01-26 18:03:53 -0800
commit2fa4eb511d63d2f0c0924664c0eb646f76f4d9dd (patch)
tree154d40239b13fcade5d0deadee18dda66058f31c /test
parent7cb15116f5702c729abdc9888120704e5a828e27 (diff)
downloadpsych-2fa4eb511d63d2f0c0924664c0eb646f76f4d9dd.zip
coder can muck with the mapping output
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_to_yaml_properties.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/psych/test_to_yaml_properties.rb b/test/psych/test_to_yaml_properties.rb
index 358c7f1..65b8e45 100644
--- a/test/psych/test_to_yaml_properties.rb
+++ b/test/psych/test_to_yaml_properties.rb
@@ -17,9 +17,16 @@ module Psych
end
class InitApi < Foo
+ attr_accessor :implicit
+ attr_accessor :style
+ attr_accessor :tag
+
def init_with coder
@a = coder['aa']
@b = coder['bb']
+ @implicit = coder.implicit
+ @tag = coder.tag
+ @style = coder.style
end
def encode_with coder
@@ -28,6 +35,29 @@ module Psych
end
end
+ class TaggingCoder < InitApi
+ def encode_with coder
+ super
+ coder.tag = coder.tag.sub(/!/, '!hello')
+ coder.implicit = false
+ coder.style = Psych::Nodes::Mapping::FLOW
+ end
+ end
+
+ def test_load_dumped_tagging
+ foo = InitApi.new
+ bar = Psych.load(Psych.dump(foo))
+ assert_equal false, bar.implicit
+ assert_equal "!ruby/object:Psych::TestToYamlProperties::InitApi", bar.tag
+ assert_equal Psych::Nodes::Mapping::BLOCK, bar.style
+ end
+
+ def test_dump_with_tag
+ foo = TaggingCoder.new
+ assert_match(/hello/, Psych.dump(foo))
+ assert_match(/{aa/, Psych.dump(foo))
+ end
+
def test_dump_encode_with
foo = InitApi.new
assert_match(/aa/, Psych.dump(foo))