diff options
author | Alexander Momchilov <alexander.momchilov@shopify.com> | 2022-07-27 10:19:37 -0400 |
---|---|---|
committer | Alexander Momchilov <alexander.momchilov@shopify.com> | 2022-07-27 15:23:33 -0400 |
commit | b9ab19094f1534c38b724a2ef76c30eb9cf5262f (patch) | |
tree | b4f34cb8cf1ebf59c6c513a84e5bb1eefab4dd5a /test/psych/test_hash.rb | |
parent | d9f7289190d424981555dec9f2c019f6a270f205 (diff) | |
download | psych-b9ab19094f1534c38b724a2ef76c30eb9cf5262f.tar.gz |
Don't hardcode expected alias names
Diffstat (limited to 'test/psych/test_hash.rb')
-rw-r--r-- | test/psych/test_hash.rb | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb index 43e4b8b..0555f6e 100644 --- a/test/psych/test_hash.rb +++ b/test/psych/test_hash.rb @@ -112,16 +112,22 @@ eoyml assert_equal({"foo"=>{"hello"=>"world"}, "bar"=>{"hello"=>"world"}}, hash) end - def test_recursive_hash_uses_alias + def test_recursive_hash h = { } h["recursive_reference"] = h - expected = <<~eoyaml - --- &1 - recursive_reference: *1 - eoyaml + loaded = Psych.load(Psych.dump(h), aliases: true) + + assert_same loaded, loaded.fetch("recursive_reference") + end + + def test_recursive_hash_uses_alias + h = { } + h["recursive_reference"] = h - assert_equal(expected, Psych.dump(h)) + assert_raise(BadAlias) do + Psych.load(Psych.dump(h), aliases: false) + end end def test_key_deduplication |