class

Spectator::Example

Inherits Spectator::Node / Reference / Object

Standard example that runs a test case.

Constructors

current

Currently running example.

Source
new(context : Context, entrypoint : self -> , name : String | Nil = nil, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil)

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.

Source
new(context : Context, entrypoint : self -> , name_proc : Example -> String, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil)

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.

Source
new(name : String | Nil = nil, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil, &block : self -> )

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.

Source

Class methods

current?

Currently running example.

Source
pending(name : String | Nil = nil, location : Location | Nil = nil, group : ExampleGroup | Nil = nil, metadata = nil, reason = nil)

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.

Source

Instance methods

ascend

Yields this example and all parent groups.

Source
finished?

Indicates whether the example already ran.

Source
group

Group the node belongs to.

Source
group?

Group the node belongs to.

Source
inspect(io : IO) : Nil

Exposes information about the example useful for debugging.

Source
procsy

Creates a procsy from this example that runs the example.

Source
procsy

Creates a procsy from this example and the provided block.

Source
result

Result of the last time the example ran. Is pending if the example hasn't run.

Source
run

Executes the test case. Returns the result of the execution. The result will also be stored in #result.

Source
to_json(json : JSON::Builder)

Creates the JSON representation of the example, which is just its name.

Source
to_s(io : IO) : Nil

Constructs the full name or description of the example. This prepends names of groups this example is part of.

Source

Nested types