Created
May 29, 2012 16:37
-
-
Save arturaz/2829447 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Raise an exception in caller context, but stay running | |
def abort(cause) | |
cause = case cause | |
when String then RuntimeError.new(cause) | |
when Exception then cause | |
else raise "Unknown abort cause class #{cause.class} for object #{cause.inspect}" | |
end | |
raise AbortError.new(cause) | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "crashes the caller if we pass neither String nor Exception" do | |
actor = actor_class.new "Al Pacino" | |
expect do | |
actor.crash_with_abort_raw 10 | |
end.to raise_exception(RuntimeError) | |
actor.should_not be_alive | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment