diff options
Diffstat (limited to 'test/psych/test_psych.rb')
-rw-r--r-- | test/psych/test_psych.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb index 88fe83c19a..22baa1489e 100644 --- a/test/psych/test_psych.rb +++ b/test/psych/test_psych.rb @@ -1,5 +1,8 @@ require_relative 'helper' +require 'stringio' +require 'tempfile' + class TestPsych < Psych::TestCase def test_dump_stream things = [22, "foo \n", {}] @@ -7,6 +10,22 @@ class TestPsych < Psych::TestCase assert_equal things, Psych.load_stream(stream) end + def test_dump_file + hash = {'hello' => 'TGIF!'} + Tempfile.open('fun.yml') do |io| + assert_equal io, Psych.dump(hash, io) + io.rewind + assert_equal Psych.dump(hash), io.read + end + end + + def test_dump_io + hash = {'hello' => 'TGIF!'} + stringio = StringIO.new '' + assert_equal stringio, Psych.dump(hash, stringio) + assert_equal Psych.dump(hash), stringio.string + end + def test_simple assert_equal 'foo', Psych.load("--- foo\n") end |