Skip to content

Commit

Permalink
[ruby/psych] Clarify tests about parsing aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov authored and matzbot committed Aug 8, 2022
1 parent 1602443 commit c851bce
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions test/psych/test_safe_load.rb
Expand Up @@ -19,18 +19,31 @@ class Foo; end
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
Expand Down

0 comments on commit c851bce

Please sign in to comment.