diff options
author | Marcus Stollsteimer <sto.mar@web.de> | 2018-04-23 20:50:05 +0200 |
---|---|---|
committer | Marcus Stollsteimer <sto.mar@web.de> | 2018-04-23 20:50:05 +0200 |
commit | 8fe50fcf2083bb36b845370ef090f58aebf669b3 (patch) | |
tree | 8102eb32c92f17db9db6c57138fd7de0b9e304b8 | |
parent | 97af871d153371e8ae42ffb371897210e3cd084e (diff) | |
download | psych-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.
-rw-r--r-- | test/psych/test_psych.rb | 18 |
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 |