diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-03-26 17:32:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-03-26 17:32:15 -0700 |
commit | 2195fb15a7b6c4f3ea17885b184f386e6cc82787 (patch) | |
tree | cd5a0b31eed6fb79d367b43bdb7aeb8382911a0c /test/psych/test_exception.rb | |
parent | 50dd7278528e4323c6fdfc2e0587616eb6a815b5 (diff) | |
download | psych-2195fb15a7b6c4f3ea17885b184f386e6cc82787.tar.gz |
moving tests under the psych directory
Diffstat (limited to 'test/psych/test_exception.rb')
-rw-r--r-- | test/psych/test_exception.rb | 46 |
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 |