summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMarcus Stollsteimer <sto.mar@web.de>2018-04-23 20:50:05 +0200
committerMarcus Stollsteimer <sto.mar@web.de>2018-04-23 20:50:05 +0200
commit8fe50fcf2083bb36b845370ef090f58aebf669b3 (patch)
tree8102eb32c92f17db9db6c57138fd7de0b9e304b8 /test
parent97af871d153371e8ae42ffb371897210e3cd084e (diff)
downloadpsych-8fe50fcf2083bb36b845370ef090f58aebf669b3.zip
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.
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_psych.rb18
1 files changed, 18 insertions, 0 deletions
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