2020-10-17 20:56:31 +00:00
|
|
|
require "./fail_result"
|
|
|
|
|
|
|
|
module Spectator
|
|
|
|
# Outcome that indicates running an example generated an error.
|
|
|
|
# This occurs when an unexpected exception was raised while running an example.
|
|
|
|
# This is different from a "failed" result in that the error was not from a failed assertion.
|
|
|
|
class ErrorResult < FailResult
|
|
|
|
# Calls the `error` method on *visitor*.
|
|
|
|
def accept(visitor)
|
2021-05-16 18:19:16 +00:00
|
|
|
visitor.error(self)
|
2020-10-17 20:56:31 +00:00
|
|
|
end
|
|
|
|
|
2021-01-31 02:42:46 +00:00
|
|
|
# Calls the `error` method on *visitor*.
|
|
|
|
def accept(visitor)
|
|
|
|
visitor.error(yield self)
|
|
|
|
end
|
|
|
|
|
2020-10-17 20:56:31 +00:00
|
|
|
# One-word description of the result.
|
2022-11-05 02:56:02 +00:00
|
|
|
def to_s(io : IO) : Nil
|
2020-10-17 20:56:31 +00:00
|
|
|
io << "error"
|
|
|
|
end
|
2021-01-31 02:42:46 +00:00
|
|
|
|
2021-06-03 04:48:48 +00:00
|
|
|
# String used for the JSON status field.
|
|
|
|
private def json_status
|
|
|
|
"error"
|
2021-01-31 02:42:46 +00:00
|
|
|
end
|
2020-10-17 20:56:31 +00:00
|
|
|
end
|
|
|
|
end
|