Skip to content

Commit

Permalink
Add specs for arguments of raise
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Oct 3, 2012
1 parent 32c35a4 commit b85c893
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/ruby/shared/kernel/raise.rb
Expand Up @@ -16,6 +16,31 @@
lambda { @object.raise }.should raise_error(RuntimeError) lambda { @object.raise }.should raise_error(RuntimeError)
end 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 it "re-raises the rescued exception" do
lambda do lambda do
begin begin
Expand Down

0 comments on commit b85c893

Please sign in to comment.