diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2018-05-21 15:01:46 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-21 15:01:46 -0700 |
commit | e01839af57df559b26f74e906062be6c692c89c8 (patch) | |
tree | 8496ecdcec183d1279cfbd205decf34021d5fada /test | |
parent | 1e050bff31872b2c4eaa81fa5feaf579d5dc2e3b (diff) | |
parent | 04ad1627b9f5eee57b64019cf2694c34c85edb10 (diff) | |
download | psych-e01839af57df559b26f74e906062be6c692c89c8.zip |
Merge pull request #346 from stomar/fix-fallback-arg
Fix fallback keyword argument of Psych.load
Diffstat (limited to 'test')
-rw-r--r-- | test/psych/test_psych.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb index 8f9a100..a67342f 100644 --- a/test/psych/test_psych.rb +++ b/test/psych/test_psych.rb @@ -135,6 +135,31 @@ class TestPsych < Psych::TestCase assert_equal({ 'hello' => 'world' }, got) end + def test_load_default_return_value + assert_equal false, Psych.load("") + end + + def test_load_with_fallback + assert_equal 42, Psych.load("", "file", fallback: 42) + end + + def test_load_with_fallback_nil_or_false + assert_nil Psych.load("", "file", fallback: nil) + assert_equal false, Psych.load("", "file", fallback: false) + end + + def test_load_with_fallback_hash + assert_equal Hash.new, Psych.load("", "file", fallback: Hash.new) + end + + def test_load_with_fallback_for_nil + assert_nil Psych.load("--- null", "file", fallback: 42) + end + + def test_load_with_fallback_for_false + assert_equal false, Psych.load("--- false", "file", fallback: 42) + end + def test_load_file Tempfile.create(['yikes', 'yml']) {|t| t.binmode |