summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authorAlexander Momchilov <alexander.momchilov@shopify.com>2022-07-21 15:07:39 -0400
committergit <svn-admin@ruby-lang.org>2022-08-09 01:32:47 +0900
commit54219ae8c46bc431782caf01142883ce7e8b970b (patch)
tree8f0cecd389935d48f3214d0ded8fb46951015562 /test/psych
parent71f89c287459d5ca313d0b1a16b7a743e0d71b8b (diff)
[ruby/psych] Raise specific error when aliases are not enabled
https://github.com/ruby/psych/commit/0c11ddcf46
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/helper.rb6
-rw-r--r--test/psych/test_array.rb2
-rw-r--r--test/psych/test_hash.rb2
-rw-r--r--test/psych/test_merge_keys.rb2
-rw-r--r--test/psych/test_object.rb2
-rw-r--r--test/psych/test_safe_load.rb2
6 files changed, 8 insertions, 8 deletions
diff --git a/test/psych/helper.rb b/test/psych/helper.rb
index 0643139d8c..4e82887c6d 100644
--- a/test/psych/helper.rb
+++ b/test/psych/helper.rb
@@ -51,7 +51,7 @@ module Psych
:UseVersion => true, :UseHeader => true, :SortKeys => true
)
))
- rescue Psych::DisallowedClass, Psych::BadAlias
+ rescue Psych::DisallowedClass, Psych::BadAlias, Psych::AliasesNotEnabled
assert_to_yaml obj, yaml, :unsafe_load
end
@@ -61,7 +61,7 @@ module Psych
def assert_parse_only( obj, yaml )
begin
assert_equal obj, Psych::load( yaml )
- rescue Psych::DisallowedClass, Psych::BadAlias
+ rescue Psych::DisallowedClass, Psych::BadAlias, Psych::AliasesNotEnabled
assert_equal obj, Psych::unsafe_load( yaml )
end
assert_equal obj, Psych::parse( yaml ).transform
@@ -79,7 +79,7 @@ module Psych
assert_equal(obj, Psych.load(v.tree.yaml))
assert_equal(obj, Psych::load(Psych.dump(obj)))
assert_equal(obj, Psych::load(obj.to_yaml))
- rescue Psych::DisallowedClass, Psych::BadAlias
+ rescue Psych::DisallowedClass, Psych::BadAlias, Psych::AliasesNotEnabled
assert_equal(obj, Psych.unsafe_load(v.tree.yaml))
assert_equal(obj, Psych::unsafe_load(Psych.dump(obj)))
assert_equal(obj, Psych::unsafe_load(obj.to_yaml))
diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb
index 6a9931ab2f..0dc82439d4 100644
--- a/test/psych/test_array.rb
+++ b/test/psych/test_array.rb
@@ -68,7 +68,7 @@ module Psych
def test_recursive_array_uses_alias
@list << @list
- assert_raise(BadAlias) do
+ assert_raise(AliasesNotEnabled) do
Psych.load(Psych.dump(@list), aliases: false)
end
end
diff --git a/test/psych/test_hash.rb b/test/psych/test_hash.rb
index 0555f6e034..0efa21160f 100644
--- a/test/psych/test_hash.rb
+++ b/test/psych/test_hash.rb
@@ -125,7 +125,7 @@ eoyml
h = { }
h["recursive_reference"] = h
- assert_raise(BadAlias) do
+ assert_raise(AliasesNotEnabled) do
Psych.load(Psych.dump(h), aliases: false)
end
end
diff --git a/test/psych/test_merge_keys.rb b/test/psych/test_merge_keys.rb
index dcf4f1fce3..8d2fceabf5 100644
--- a/test/psych/test_merge_keys.rb
+++ b/test/psych/test_merge_keys.rb
@@ -117,7 +117,7 @@ development:
bar:
<< : *foo
eoyml
- exp = assert_raise(Psych::BadAlias) { Psych.load yaml }
+ exp = assert_raise(Psych::BadAlias) { Psych.load(yaml, aliases: true) }
assert_match 'foo', exp.message
end
diff --git a/test/psych/test_object.rb b/test/psych/test_object.rb
index 227a1d1d53..21c27794ea 100644
--- a/test/psych/test_object.rb
+++ b/test/psych/test_object.rb
@@ -46,7 +46,7 @@ module Psych
foo = Foo.new(nil)
foo.parent = foo
- assert_raise(BadAlias) do
+ assert_raise(AliasesNotEnabled) do
Psych.load(Psych.dump(foo), permitted_classes: [Foo], aliases: false)
end
end
diff --git a/test/psych/test_safe_load.rb b/test/psych/test_safe_load.rb
index e57dbcb2f5..a9ed737528 100644
--- a/test/psych/test_safe_load.rb
+++ b/test/psych/test_safe_load.rb
@@ -28,7 +28,7 @@ module Psych
b: *ABC
YAML
- assert_raise(Psych::BadAlias) do
+ assert_raise(Psych::AliasesNotEnabled) do
Psych.safe_load(yaml_with_aliases)
end
end