summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_merge_keys.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb
index bf5968ff86..c31f9b80c0 100644
--- a/test/psych/test_merge_keys.rb
+++ b/test/psych/test_merge_keys.rb
@@ -2,6 +2,57 @@ require 'psych/helper'
module Psych
class TestMergeKeys < TestCase
+ def test_merge_nil
+ yaml = <<-eoyml
+defaults: &defaults
+development:
+ <<: *defaults
+ eoyml
+ assert_equal({'<<' => nil }, Psych.load(yaml)['development'])
+ end
+
+ def test_merge_array
+ yaml = <<-eoyml
+foo: &hello
+- 1
+baz:
+ <<: *hello
+ eoyml
+ assert_equal({'<<' => [1]}, Psych.load(yaml)['baz'])
+ end
+
+ def test_merge_is_not_partial
+ yaml = <<-eoyml
+default: &default
+ hello: world
+foo: &hello
+- 1
+baz:
+ <<: [*hello, *default]
+ eoyml
+ doc = Psych.load yaml
+ refute doc['baz'].key? 'hello'
+ assert_equal({'<<' => [[1], {"hello"=>"world"}]}, Psych.load(yaml)['baz'])
+ end
+
+ def test_merge_seq_nil
+ yaml = <<-eoyml
+foo: &hello
+baz:
+ <<: [*hello]
+ eoyml
+ assert_equal({'<<' => [nil]}, Psych.load(yaml)['baz'])
+ end
+
+ def test_bad_seq_merge
+ yaml = <<-eoyml
+defaults: &defaults [1, 2, 3]
+development:
+ <<: *defaults
+ eoyml
+ assert_equal({'<<' => [1,2,3]}, Psych.load(yaml)['development'])
+ end
+
def test_missing_merge_key
yaml = <<-eoyml
bar: