summaryrefslogtreecommitdiff
path: root/test/psych
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2020-09-10 15:12:11 +0200
committerHiroshi SHIBATA <hsbt@ruby-lang.org>2020-09-25 13:11:33 +0900
commitb72f9200acf88e60c850a2d400554ff38f81194d (patch)
treea36d4a76d41c19dafeb06c89b16a72ac7db6db3e /test/psych
parent8ea1021f1979c04b3cee2a886fb52a914472dd16 (diff)
downloadruby-b72f9200acf88e60c850a2d400554ff38f81194d.tar.gz
[ruby/psych] Forward keyword arguments in load_file and load_stream
https://github.com/ruby/psych/commit/4e1dd37f09
Diffstat (limited to 'test/psych')
-rw-r--r--test/psych/test_psych.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 55d9f19312..7219e8395e 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -125,6 +125,19 @@ class TestPsych < Psych::TestCase
assert_equal %w{ foo bar }, docs
end
+ def test_load_stream_freeze
+ docs = Psych.load_stream("--- foo\n...\n--- bar\n...", freeze: true)
+ assert_equal %w{ foo bar }, docs
+ docs.each do |string|
+ assert_predicate string, :frozen?
+ end
+ end
+
+ def test_load_stream_symbolize_names
+ docs = Psych.load_stream("---\nfoo: bar", symbolize_names: true)
+ assert_equal [{foo: 'bar'}], docs
+ end
+
def test_load_stream_default_fallback
assert_equal [], Psych.load_stream("")
end
@@ -242,6 +255,27 @@ class TestPsych < Psych::TestCase
}
end
+ def test_load_file_freeze
+ Tempfile.create(['yikes', 'yml']) {|t|
+ t.binmode
+ t.write('--- hello world')
+ t.close
+
+ object = Psych.load_file(t.path, freeze: true)
+ assert_predicate object, :frozen?
+ }
+ end
+
+ def test_load_file_symbolize_names
+ Tempfile.create(['yikes', 'yml']) {|t|
+ t.binmode
+ t.write("---\nfoo: bar")
+ t.close
+
+ assert_equal({foo: 'bar'}, Psych.load_file(t.path, symbolize_names: true))
+ }
+ end
+
def test_load_file_default_fallback
Tempfile.create(['empty', 'yml']) {|t|
assert_equal false, Psych.load_file(t.path)