summaryrefslogtreecommitdiff
path: root/test/psych/test_psych.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-31 21:09:58 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-31 21:09:58 +0000
commita4dbc2ea1020a0a393a0134cc900397a895a88e7 (patch)
tree93d9e2fd0f71104982884e31ea661d7d8d9504bd /test/psych/test_psych.rb
parentc97f5f514a63f2b5ed909aec270e89efb0c2703d (diff)
* ext/psych/lib/psych.rb: Syck api compatibility [ruby-core:29157]
* ext/psych/lib/psych/nodes/node.rb: ditto * test/psych/test_psych.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/psych/test_psych.rb')
-rw-r--r--test/psych/test_psych.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 88fe83c..22baa14 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