Permalink
Browse files

Add specs for arguments of raise

  • Loading branch information...
1 parent 32c35a4 commit b85c893eed541ba02d853cd16dcb9de8608ef31f @ryoqun ryoqun committed Oct 2, 2012
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

0 comments on commit b85c893

Please sign in to comment.