summaryrefslogtreecommitdiff
path: root/lib/rubygems/test_case.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-17 11:59:59 +0900
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2021-05-28 11:52:32 +0900
commitf7d661e783e02f87e1e0d0d67b1ca2ed306a1904 (patch)
treeabf49de2ba766872075576e38c9f819c7040fa21 /lib/rubygems/test_case.rb
parentded7dd9ccc6d084c5e65689ddcbcd27df703e58e (diff)
[rubygems/rubygems] Try fix ruby-core CI
* Port https://github.com/ruby/ruby/commit/8e91b969df08b7a2eb27a5d6d38733eea42dc7ad from ruby-core, and make it compatible with psych 3 & 4.
Diffstat (limited to 'lib/rubygems/test_case.rb')
-rw-r--r--lib/rubygems/test_case.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/rubygems/test_case.rb b/lib/rubygems/test_case.rb
index 8dde20452e..b3e23360ed 100644
--- a/lib/rubygems/test_case.rb
+++ b/lib/rubygems/test_case.rb
@@ -692,6 +692,28 @@ class Gem::TestCase < Test::Unit::TestCase
path
end
+ ##
+ # Load a YAML string, the psych 3 way
+
+ def load_yaml(yaml)
+ if YAML.respond_to?(:unsafe_load)
+ YAML.unsafe_load(yaml)
+ else
+ YAML.load(yaml)
+ end
+ end
+
+ ##
+ # Load a YAML file, the psych 3 way
+
+ def load_yaml_file(file)
+ if YAML.respond_to?(:unsafe_load_file)
+ YAML.unsafe_load_file(file)
+ else
+ YAML.load_file(file)
+ end
+ end
+
def all_spec_names
Gem::Specification.map(&:full_name)
end