2020-09-05 21:01:22 +00:00
|
|
|
require "./context_delegate"
|
|
|
|
require "./example_base"
|
|
|
|
require "./example_group"
|
|
|
|
require "./result"
|
|
|
|
require "./source"
|
2018-10-14 23:10:12 +00:00
|
|
|
|
2018-08-19 07:15:32 +00:00
|
|
|
module Spectator
|
2020-09-05 21:01:22 +00:00
|
|
|
# Standard example that runs a test case.
|
|
|
|
class Example < ExampleBase
|
|
|
|
# Indicates whether the example already ran.
|
|
|
|
getter? finished : Bool = false
|
|
|
|
|
|
|
|
# Retrieves the result of the last time the example ran.
|
|
|
|
getter! result : Result
|
|
|
|
|
|
|
|
# Creates the example.
|
|
|
|
# The *delegate* contains the test context and method that runs the test case.
|
|
|
|
# The *name* describes the purpose of the example.
|
|
|
|
# It can be a `Symbol` to describe a type.
|
|
|
|
# The *source* tracks where the example exists in source code.
|
|
|
|
# The example will be assigned to *group* if it is provided.
|
|
|
|
def initialize(@delegate : ContextDelegate,
|
2020-09-05 21:55:28 +00:00
|
|
|
name : String | Symbol? = nil, source : Source? = nil, group : ExampleGroup? = nil)
|
2020-09-05 21:01:22 +00:00
|
|
|
super(name, source, group)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Executes the test case.
|
|
|
|
# Returns the result of the execution.
|
|
|
|
# The result will also be stored in `#result`.
|
2018-10-10 19:05:17 +00:00
|
|
|
def run : Result
|
2020-09-05 21:01:22 +00:00
|
|
|
raise NotImplementedError.new("#run")
|
2019-03-23 03:29:20 +00:00
|
|
|
end
|
2018-08-19 07:15:32 +00:00
|
|
|
end
|
|
|
|
end
|