From 9ae2651d1929891a443eb6a208fb1038c23b86e0 Mon Sep 17 00:00:00 2001 From: tenderlove Date: Tue, 5 Nov 2013 19:15:40 +0000 Subject: * ext/psych/lib/psych/visitors/to_ruby.rb: process merge keys before reviving objects. Fixes GH psych #168 * test/psych/test_merge_keys.rb: test for change https://github.com/tenderlove/psych/issues/168 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/psych/test_merge_keys.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/psych') diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb index d8baba485f..ba8d2e77b3 100644 --- a/test/psych/test_merge_keys.rb +++ b/test/psych/test_merge_keys.rb @@ -2,6 +2,24 @@ require_relative 'helper' module Psych class TestMergeKeys < TestCase + class Product + attr_reader :bar + end + + def test_mergekey_with_object + s = <<-eoyml +foo: &foo + bar: 10 +product: + !ruby/object:#{Product.name} + <<: *foo + eoyml + hash = Psych.load s + assert_equal({"bar" => 10}, hash["foo"]) + product = hash["product"] + assert_equal 10, product.bar + end + def test_merge_nil yaml = <<-eoyml defaults: &defaults -- cgit v1.2.3