summaryrefslogtreecommitdiff
path: root/test/psych/test_exception.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-03-26 17:32:15 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-03-26 17:32:15 -0700
commit2195fb15a7b6c4f3ea17885b184f386e6cc82787 (patch)
treecd5a0b31eed6fb79d367b43bdb7aeb8382911a0c /test/psych/test_exception.rb
parent50dd7278528e4323c6fdfc2e0587616eb6a815b5 (diff)
downloadpsych-2195fb15a7b6c4f3ea17885b184f386e6cc82787.tar.gz
moving tests under the psych directory
Diffstat (limited to 'test/psych/test_exception.rb')
-rw-r--r--test/psych/test_exception.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/psych/test_exception.rb b/test/psych/test_exception.rb
new file mode 100644
index 0000000..b4d821e
--- /dev/null
+++ b/test/psych/test_exception.rb
@@ -0,0 +1,46 @@
+require 'minitest/autorun'
+require 'psych'
+
+module Psych
+ class TestException < MiniTest::Unit::TestCase
+ class Wups < Exception
+ attr_reader :foo, :bar
+ def initialize *args
+ super
+ @foo = 1
+ @bar = 2
+ end
+ end
+
+ def setup
+ @wups = Wups.new
+ end
+
+ def test_to_yaml
+ w = Psych.load(@wups.to_yaml)
+ assert_equal @wups, w
+ assert_equal 1, w.foo
+ assert_equal 2, w.bar
+ end
+
+ def test_dump
+ w = Psych.load(@wups.to_yaml)
+ assert_equal @wups, w
+ assert_equal 1, w.foo
+ assert_equal 2, w.bar
+ end
+
+ def test_to_yaml_properties
+ class << @wups
+ def to_yaml_properties
+ [:@foo]
+ end
+ end
+
+ w = Psych.load(Psych.dump(@wups))
+ assert_equal @wups, w
+ assert_equal 1, w.foo
+ assert_nil w.bar
+ end
+ end
+end