diff options
author | Marc-Andre Lafortune <github@marc-andre.ca> | 2021-06-14 10:15:11 -0400 |
---|---|---|
committer | Marc-André Lafortune <github@marc-andre.ca> | 2021-06-14 12:28:53 -0400 |
commit | a09ddfc4207cce58693f2226ebbbc4b8f009fb23 (patch) | |
tree | df4feb56eef047c2849d0e4b66486b9136d2dee2 | |
parent | 52369fc545c458efb2fa7e8ca183b119252bb4f9 (diff) | |
download | ruby-a09ddfc4207cce58693f2226ebbbc4b8f009fb23.tar.gz |
[lib/ostruct] Fix YAML test
-rw-r--r-- | test/ostruct/test_ostruct.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/test/ostruct/test_ostruct.rb b/test/ostruct/test_ostruct.rb index d2aad4428f..d857d5c66a 100644 --- a/test/ostruct/test_ostruct.rb +++ b/test/ostruct/test_ostruct.rb @@ -370,18 +370,18 @@ class TC_OpenStruct < Test::Unit::TestCase 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) |