Skip to content

Commit

Permalink
Merge pull request #110 from bmulvihill/expect-raises
Browse files Browse the repository at this point in the history
[spec] Fix generic expect_raises
  • Loading branch information
faultyserver authored Dec 31, 2017
2 parents 7df9e5c + 0aa96c7 commit 2fd6706
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions stdlib/spec/single_spec.mt
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ defmodule Spec
# a specific error.
def expect_raises(&block)
block()
raise %AssertionFailure{@name, expected_error, "no error"}
raise %AssertionFailure{@name, "Any Error", "no error"}
rescue ex : AssertionFailure
# Rescuing an AssertionFailure implies that `block` did
# not raise an exception, so the exception is re-raised.
raise ex
rescue
# If an error was raised, the assertion passes.
# Otherwise, the error must have come from `block`, so the
# assertion is successful.
end
end
end

0 comments on commit 2fd6706

Please sign in to comment.