class Spectator::Example
Overview
Standard example that runs a test case.
Defined in:
spectator/example.crConstructors
-
.current : Example
Currently running example.
-
.new(context : Context, entrypoint : self -> , name : String | Nil = nil, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil)
Creates the example.
-
.new(context : Context, entrypoint : self -> , name_proc : Example -> String, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil)
Creates the example.
-
.new(name : String | Nil = nil, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil, &block : self -> )
Creates a dynamic example.
Class Method Summary
-
.current? : Example | Nil
Currently running example.
-
.pending(name : String | Nil = nil, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil, reason = nil)
Creates a pending example.
Instance Method Summary
-
#ascend(&)
Yields this example and all parent groups.
-
#finished? : Bool
Indicates whether the example already ran.
-
#group : ExampleGroup
Group the node belongs to.
-
#group? : ExampleGroup | Nil
Group the node belongs to.
-
#inspect(io : IO) : Nil
Exposes information about the example useful for debugging.
-
#procsy
Creates a procsy from this example that runs the example.
-
#procsy(&block : -> )
Creates a procsy from this example and the provided block.
-
#result : Result
Result of the last time the example ran.
-
#run : Result
Executes the test case.
-
#to_json(json : JSON::Builder)
Creates the JSON representation of the example, which is just its name.
-
#to_s(io : IO) : Nil
Constructs the full name or description of the example.
Instance methods inherited from class Spectator::Node
display_name
display_name,
finished? : Bool
finished?,
inspect(io : IO) : Nil
inspect,
location : Location
location,
location? : Location | Nil
location?,
metadata : Metadata
metadata,
name : Label
name,
name? : Label | Nil
name?,
pending?
pending?,
pending_reason
pending_reason,
tags
tags,
to_s(io : IO) : Nil
to_s
Constructor methods inherited from class Spectator::Node
new(name : Label = nil, location : Location | Nil = nil, metadata : Metadata | Nil = nil)
new
Instance methods inherited from class Object
should(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall Ushould(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should, should_eventually(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_eventually, should_never(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_never, should_not(matcher : Spectator::Matchers::TypeMatcher(U), message = nil, *, _file = __FILE__, _line = __LINE__) forall U
should_not(matcher : Spectator::Matchers::NilMatcher, message = nil, *, _file = __FILE__, _line = __LINE__)
should_not(matcher, message = nil, *, _file = __FILE__, _line = __LINE__) should_not
Constructor Detail
Creates the example. An instance to run the test code in is given by context. The entrypoint defines the test code (typically inside context). The name describes the purpose of the example. The location tracks where the example exists in source code. The example will be assigned to group if it is provided. A set of metadata can be used for filtering and modifying example behavior. Note: The metadata will not be merged with the parent metadata.
Creates the example. An instance to run the test code in is given by context. The entrypoint defines the test code (typically inside context). The name describes the purpose of the example. It can be a proc to be evaluated in the context of the example. The location tracks where the example exists in source code. The example will be assigned to group if it is provided. A set of metadata can be used for filtering and modifying example behavior. Note: The metadata will not be merged with the parent metadata.
Creates a dynamic example.
A block provided to this method will be called as-if it were the test code for the example.
The block will be given this example instance as an argument.
The name describes the purpose of the example.
It can be a Symbol
to describe a type.
The location tracks where the example exists in source code.
The example will be assigned to group if it is provided.
A set of metadata can be used for filtering and modifying example behavior.
Note: The metadata will not be merged with the parent metadata.
Class Method Detail
Creates a pending example.
The name describes the purpose of the example.
It can be a Symbol
to describe a type.
The location tracks where the example exists in source code.
The example will be assigned to group if it is provided.
A set of metadata can be used for filtering and modifying example behavior.
Note: The metadata will not be merged with the parent metadata.
Instance Method Detail
Result of the last time the example ran. Is pending if the example hasn't run.
Executes the test case.
Returns the result of the execution.
The result will also be stored in #result
.
Creates the JSON representation of the example, which is just its name.
Constructs the full name or description of the example. This prepends names of groups this example is part of.