[前][次][番号順一覧][スレッド一覧]

ruby-changes:66486

From: Marc-Andre <ko1@a...>
Date: Tue, 15 Jun 2021 01:29:10 +0900 (JST)
Subject: [ruby-changes:66486] a09ddfc420 (master): [lib/ostruct] Fix YAML test

https://git.ruby-lang.org/ruby.git/commit/?id=a09ddfc420

From a09ddfc4207cce58693f2226ebbbc4b8f009fb23 Mon Sep 17 00:00:00 2001
From: Marc-Andre Lafortune <github@m...>
Date: Mon, 14 Jun 2021 10:15:11 -0400
Subject: [lib/ostruct] Fix YAML test

---
 test/ostruct/test_ostruct.rb | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb
index d2aad44..d857d5c 100644
--- a/test/ostruct/test_ostruct.rb
+++ b/test/ostruct/test_ostruct.rb
@@ -370,18 +370,18 @@ class TC_OpenStruct < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ostruct/test_ostruct.rb#L370
 
   def test_legacy_yaml
     s = "--- !ruby/object:OpenStruct\ntable:\n  :foo: 42\n"
-    o = YAML.unsafe_load(s)
+    o = YAML.safe_load(s, permitted_classes: [Symbol, OpenStruct])
     assert_equal(42, o.foo)
 
     o = OpenStruct.new(table: {foo: 42})
-    assert_equal({foo: 42}, YAML.unsafe_load(YAML.dump(o)).table)
+    assert_equal({foo: 42}, YAML.safe_load(YAML.dump(o), permitted_classes: [Symbol, OpenStruct]).table)
   end
 
   def test_yaml
     h = {name: "John Smith", age: 70, pension: 300.42}
     yaml = "--- !ruby/object:OpenStruct\nname: John Smith\nage: 70\npension: 300.42\n"
     os1 = OpenStruct.new(h)
-    os2 = YAML.unsafe_load(os1.to_yaml)
+    os2 = YAML.safe_load(os1.to_yaml, permitted_classes: [Symbol, OpenStruct])
     assert_equal yaml, os1.to_yaml
     assert_equal os1, os2
     assert_equal true, os1.eql?(os2)
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]