Handle errored and failing specs separately

An errored example is one that throws an exception that is not from an 
expectation failing.
This commit is contained in:
Michael Miller 2018-08-30 21:15:20 -06:00
parent 65b16f9031
commit c100651680
2 changed files with 18 additions and 2 deletions

View file

@ -0,0 +1,14 @@
require "./failed_example_result"
module Spectator
class ErroredExampleResult < FailedExampleResult
getter error : Exception
def errored? : Bool
true
end
def initialize(@example, @error)
end
end
end

View file

@ -19,8 +19,10 @@ module Spectator
private def run_example(example)
example.run
SuccessfulExampleResult.new(example)
rescue ex : Exception
FailedExampleResult.new(example, ex)
rescue failure : ExpectationFailedError
FailedExampleResult.new(example, failure)
rescue ex
ErroredExampleResult.new(example, ex)
end
end
end