2020-10-17 20:56:31 +00:00
|
|
|
require "./result"
|
|
|
|
|
|
|
|
module Spectator
|
|
|
|
# Outcome that indicates running an example was successful.
|
|
|
|
class PassResult < Result
|
|
|
|
# Calls the `pass` method on *visitor*.
|
|
|
|
def accept(visitor)
|
2021-05-16 18:19:16 +00:00
|
|
|
visitor.pass(self)
|
2020-10-17 20:56:31 +00:00
|
|
|
end
|
|
|
|
|
2021-01-31 02:42:46 +00:00
|
|
|
# Calls the `pass` method on *visitor*.
|
2023-01-27 00:19:31 +00:00
|
|
|
def accept(visitor, &)
|
2021-01-31 02:42:46 +00:00
|
|
|
visitor.pass(yield self)
|
|
|
|
end
|
|
|
|
|
2021-05-13 03:39:50 +00:00
|
|
|
# Indicates whether the example passed.
|
|
|
|
def pass? : Bool
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
# Indicates whether the example failed.
|
|
|
|
def fail? : Bool
|
|
|
|
false
|
|
|
|
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 << "pass"
|
|
|
|
end
|
2021-06-03 04:48:48 +00:00
|
|
|
|
|
|
|
# Creates a JSON object from the result information.
|
|
|
|
def to_json(json : JSON::Builder)
|
|
|
|
super
|
|
|
|
json.field("status", "passed")
|
|
|
|
end
|
2020-10-17 20:56:31 +00:00
|
|
|
end
|
|
|
|
end
|