From 8fe50fcf2083bb36b845370ef090f58aebf669b3 Mon Sep 17 00:00:00 2001 From: Marcus Stollsteimer Date: Mon, 23 Apr 2018 20:50:05 +0200 Subject: Add more test cases for fallback of Psych.load_file Add test cases for the fallback keyword argument of Psych.load_file to make sure that the fallback is not used for valid YAML that represents nil or false. --- test/psych/test_psych.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test') diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb index 2d4a7cc..bce6bf8 100644 --- a/test/psych/test_psych.rb +++ b/test/psych/test_psych.rb @@ -162,6 +162,24 @@ class TestPsych < Psych::TestCase } end + def test_load_file_with_fallback_for_nil + Tempfile.create(['nil', 'yml']) {|t| + t.binmode + t.write('--- null') + t.close + assert_nil Psych.load_file(t.path, fallback: 42) + } + end + + def test_load_file_with_fallback_for_false + Tempfile.create(['false', 'yml']) {|t| + t.binmode + t.write('--- false') + t.close + assert_equal false, Psych.load_file(t.path, fallback: 42) + } + end + def test_parse_file Tempfile.create(['yikes', 'yml']) {|t| t.binmode -- cgit v1.2.3