diff options
author | Alexander Momchilov <alexander.momchilov@shopify.com> | 2022-07-22 15:49:05 -0400 |
---|---|---|
committer | Alexander Momchilov <alexander.momchilov@shopify.com> | 2022-07-22 15:50:25 -0400 |
commit | 0bc30cb4cb03164fb60cab7f0d2eb27fd6e78193 (patch) | |
tree | 3b4823ac694524bb25114911846a974833e24cb1 /test | |
parent | 74fb0be6a07b0564ed58430efc3dc38a60411b63 (diff) | |
download | psych-0bc30cb4cb03164fb60cab7f0d2eb27fd6e78193.tar.gz |
Clarify tests about parsing aliases
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_safe_load.rb | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/test/psych/test_safe_load.rb b/test/psych/test_safe_load.rb index b52d604..e57dbcb 100644 --- a/test/psych/test_safe_load.rb +++ b/test/psych/test_safe_load.rb @@ -19,18 +19,31 @@ module Psych end end - def test_no_recursion - x = [] - x << x + def test_raises_when_alias_found_if_alias_parsing_not_enabled + yaml_with_aliases = <<~YAML + --- + a: &ABC + k1: v1 + k2: v2 + b: *ABC + YAML + assert_raise(Psych::BadAlias) do - Psych.safe_load Psych.dump(x) + Psych.safe_load(yaml_with_aliases) end end - def test_explicit_recursion - x = [] - x << x - assert_equal(x, Psych.safe_load(Psych.dump(x), permitted_classes: [], permitted_symbols: [], aliases: true)) + def test_aliases_are_parsed_when_alias_parsing_is_enabled + yaml_with_aliases = <<~YAML + --- + a: &ABC + k1: v1 + k2: v2 + b: *ABC + YAML + + result = Psych.safe_load(yaml_with_aliases, aliases: true) + assert_same result.fetch("a"), result.fetch("b") end def test_permitted_symbol |