Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add specs for arguments of raise

  • Loading branch information...
commit b85c893eed541ba02d853cd16dcb9de8608ef31f 1 parent 32c35a4
@ryoqun authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 spec/ruby/shared/kernel/raise.rb
View
25 spec/ruby/shared/kernel/raise.rb
@@ -16,6 +16,31 @@
lambda { @object.raise }.should raise_error(RuntimeError)
end
+ it "raises a given Exception instance" do
+ error = RuntimeError.new
+ lambda { @object.raise(error) }.should raise_error(error)
+ end
+
+ it "raises a RuntimeError if string given" do
+ lambda { @object.raise("a bad thing") }.should raise_error(RuntimeError)
+ end
+
+ it "raises a TypeError when passed a non-Exception object" do
+ lambda { @object.raise(Object.new) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed true" do
+ lambda { @object.raise(true) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed false" do
+ lambda { @object.raise(false) }.should raise_error(TypeError)
+ end
+
+ it "raises a TypeError when passed nil" do
+ lambda { @object.raise(nil) }.should raise_error(TypeError)
+ end
+
it "re-raises the rescued exception" do
lambda do
begin
Please sign in to comment.
Something went wrong with that request. Please try again.