From d28928569780d564e944b3a59b012ad40f10b93f Mon Sep 17 00:00:00 2001 From: Jeff Wallace Date: Fri, 25 Jan 2013 12:20:37 -0800 Subject: Fix case when map includes a symbol key in #emit_coder Mimic what is done in #visit_Hash. Fixes #107. --- lib/psych/visitors/yaml_tree.rb | 2 +- test/psych/test_coder.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index ce40a17..51445f7 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -440,7 +440,7 @@ module Psych when :map @emitter.start_mapping nil, c.tag, c.implicit, c.style c.map.each do |k,v| - @emitter.scalar k, nil, nil, true, false, Nodes::Scalar::ANY + accept k accept v end @emitter.end_mapping diff --git a/test/psych/test_coder.rb b/test/psych/test_coder.rb index 7539c7d..58769ad 100644 --- a/test/psych/test_coder.rb +++ b/test/psych/test_coder.rb @@ -85,7 +85,7 @@ module Psych end def encode_with coder - coder.represent_map self.class.name, { 'a' => 'b' } + coder.represent_map self.class.name, { "string" => 'a', :symbol => 'b' } end end @@ -131,7 +131,7 @@ module Psych def test_represent_map thing = Psych.load(Psych.dump(RepresentWithMap.new)) - assert_equal({ 'a' => 'b' }, thing.map) + assert_equal({ "string" => 'a', :symbol => 'b' }, thing.map) end def test_represent_sequence -- cgit v1.2.3