summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-29 01:23:54 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-29 01:23:54 +0000
commit0f9307914b08a60102d29cee2260358bd2aaac75 (patch)
treea1a95d6ff3d4be580f98b6ada33c33c154c11b57 /test
parent87b248dc4d4bed790fc402756993d64962ed8595 (diff)
* ext/psych/lib/psych/handlers/recorder.rb: added a class for
recording YAML parse and emit events. * ext/psych/lib/psych/handler.rb: adding a list of events so that handler classes can more easily be meta-programmed. * test/psych/handlers/test_recorder.rb: tests for the change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/psych/handlers/test_recorder.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/psych/handlers/test_recorder.rb b/test/psych/handlers/test_recorder.rb
new file mode 100644
index 0000000000..96b8eac1fc
--- /dev/null
+++ b/test/psych/handlers/test_recorder.rb
@@ -0,0 +1,25 @@
+require 'psych/helper'
+require 'psych/handlers/recorder'
+
+module Psych
+ module Handlers
+ class TestRecorder < TestCase
+ def test_replay
+ yaml = "--- foo\n...\n"
+ output = StringIO.new
+
+ recorder = Psych::Handlers::Recorder.new
+ parser = Psych::Parser.new recorder
+ parser.parse yaml
+
+ assert_equal 5, recorder.events.length
+
+ emitter = Psych::Emitter.new output
+ recorder.events.each do |m, args|
+ emitter.send m, *args
+ end
+ assert_equal yaml, output.string
+ end
+ end
+ end
+end