Skip to content

Commit 0bc30cb

Browse files
committed
Clarify tests about parsing aliases
1 parent 74fb0be commit 0bc30cb

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

test/psych/test_safe_load.rb

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,31 @@ class Foo; end
1919
end
2020
end
2121

22-
def test_no_recursion
23-
x = []
24-
x << x
22+
def test_raises_when_alias_found_if_alias_parsing_not_enabled
23+
yaml_with_aliases = <<~YAML
24+
---
25+
a: &ABC
26+
k1: v1
27+
k2: v2
28+
b: *ABC
29+
YAML
30+
2531
assert_raise(Psych::BadAlias) do
26-
Psych.safe_load Psych.dump(x)
32+
Psych.safe_load(yaml_with_aliases)
2733
end
2834
end
2935

30-
def test_explicit_recursion
31-
x = []
32-
x << x
33-
assert_equal(x, Psych.safe_load(Psych.dump(x), permitted_classes: [], permitted_symbols: [], aliases: true))
36+
def test_aliases_are_parsed_when_alias_parsing_is_enabled
37+
yaml_with_aliases = <<~YAML
38+
---
39+
a: &ABC
40+
k1: v1
41+
k2: v2
42+
b: *ABC
43+
YAML
44+
45+
result = Psych.safe_load(yaml_with_aliases, aliases: true)
46+
assert_same result.fetch("a"), result.fetch("b")
3447
end
3548

3649
def test_permitted_symbol

0 commit comments

Comments
 (0)