summaryrefslogtreecommitdiff
path: root/test/psych/test_exception.rb
diff options
context:
space:
mode:
authorEric Hodel <drbrain@segment7.net>2012-10-22 13:45:48 -0700
committerEric Hodel <drbrain@segment7.net>2012-10-22 13:45:48 -0700
commit66e22be9d7e33eb79b204a7d55ebc5abd5284e4d (patch)
tree045a66f796d045b9cb55d700a1b71d28a36214df /test/psych/test_exception.rb
parent99f60a439a75bea57a3c62135c3b020ddc93360b (diff)
downloadpsych-66e22be9d7e33eb79b204a7d55ebc5abd5284e4d.zip
Psych::SyntaxError now inherits from RuntimeError
Previously Psych::SyntaxError inherited from SyntaxError. Since SyntaxError does not inherit from StandardError a plain rescue could not capture a YAML parse error. This made code that needed to handle psych errors slightly more complex. Psych::SyntaxError now inherits from Psych::Error (allowing room for future expansion of psych errors that can be caught under the same umbrella) and inherits from RuntimeError.
Diffstat (limited to 'test/psych/test_exception.rb')
-rw-r--r--test/psych/test_exception.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/psych/test_exception.rb b/test/psych/test_exception.rb
index c6d98d7..5615fc2 100644
--- a/test/psych/test_exception.rb
+++ b/test/psych/test_exception.rb
@@ -126,5 +126,26 @@ module Psych
assert_equal 1, w.foo
assert_nil w.bar
end
+
+ def test_psych_syntax_error
+ Tempfile.open(['parsefile', 'yml']) do |t|
+ t.binmode
+ t.write '--- `'
+ t.close
+
+ begin
+ Psych.parse_file t.path
+ rescue StandardError
+ assert true # count assertion
+ ensure
+ return unless $!
+
+ ancestors = $!.class.ancestors.inspect
+
+ flunk "Psych::SyntaxError not rescued by StandardError: #{ancestors}"
+ end
+ end
+ end
+
end
end