summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-07 14:17:11 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-07 14:17:11 -0700
commite2f8e49de26b5473d679adb9d8f91ed824a51fa9 (patch)
tree882301906db1b3d67c0c65f0532a1af69d76aaf7 /test
parenta5a87e37c7ee522b36b1d43dc78a0f7a50d41efc (diff)
downloadpsych-e2f8e49de26b5473d679adb9d8f91ed824a51fa9.zip
options are being used, :canonical and :indentation are supported
Diffstat (limited to 'test')
-rw-r--r--test/psych/test_psych.rb10
-rw-r--r--test/psych/visitors/test_emitter.rb20
2 files changed, 30 insertions, 0 deletions
diff --git a/test/psych/test_psych.rb b/test/psych/test_psych.rb
index 0d33cb1..f3f3a53 100644
--- a/test/psych/test_psych.rb
+++ b/test/psych/test_psych.rb
@@ -8,6 +8,16 @@ class TestPsych < Psych::TestCase
Psych.domain_types.clear
end
+ def test_indent
+ yml = Psych.dump({:a => {'b' => 'c'}}, {:indentation => 5})
+ assert_match(/^[ ]{5}b/, yml)
+ end
+
+ def test_canonical
+ yml = Psych.dump({:a => {'b' => 'c'}}, {:canonical => true})
+ assert_match(/\? ! "b/, yml)
+ end
+
def test_load_argument_error
assert_raises(TypeError) do
Psych.load nil
diff --git a/test/psych/visitors/test_emitter.rb b/test/psych/visitors/test_emitter.rb
index bdae1bd..7847cea 100644
--- a/test/psych/visitors/test_emitter.rb
+++ b/test/psych/visitors/test_emitter.rb
@@ -9,6 +9,26 @@ module Psych
@visitor = Visitors::Emitter.new @io
end
+ def test_options
+ io = StringIO.new
+ visitor = Visitors::Emitter.new io, :indentation => 3
+
+ s = Nodes::Stream.new
+ doc = Nodes::Document.new
+ mapping = Nodes::Mapping.new
+ m2 = Nodes::Mapping.new
+ m2.children << Nodes::Scalar.new('a')
+ m2.children << Nodes::Scalar.new('b')
+
+ mapping.children << Nodes::Scalar.new('key')
+ mapping.children << m2
+ doc.children << mapping
+ s.children << doc
+
+ visitor.accept s
+ assert_match(/^[ ]{3}a/, io.string)
+ end
+
def test_stream
s = Nodes::Stream.new
@visitor.accept s