abstract class Spectator::Example
Overview
Base class for all types of examples.
Concrete types must implement the #run_impl
method.
Direct Known Subclasses
Defined in:
spectator/example.crConstructors
-
.new(group : Spectator::ExampleGroup, test_wrapper : Spectator::TestWrapper)
Creates the base of the example.
Instance Method Summary
-
#[](index : Int) : Example
Retrieve the current example.
-
#description : String | Symbol
Text that describes the context or test.
-
#example_count : Int
Indicates there is only one example to run.
-
#finished? : Bool
Indicates whether the example has already been run.
-
#group : ExampleGroup
Group that the example belongs to.
-
#run : Result
Runs the example code.
- #run_impl
-
#source : Source
Source where the example originated from.
-
#symbolic? : Bool
Indicates that the component references a type or method.
-
#to_json(json : JSON::Builder)
Creates the JSON representation of the example, which is just its name.
-
#to_s(io)
String representation of the example.
Instance methods inherited from class Spectator::ExampleComponent
[](index : Int) : Example
[],
description : Symbol | String
description,
example_count : Int
example_count,
finished? : Bool
finished?,
full_description
full_description,
source : Source
source,
symbolic? : Bool
symbolic?
Instance methods inherited from class Object
should(matcher)
should,
should_eventually(matcher)
should_eventually,
should_never(matcher)
should_never,
should_not(matcher)
should_not
Constructor Detail
Creates the base of the example. The group should be the example group the example belongs to.
Instance Method Detail
Text that describes the context or test.
Runs the example code. A result is returned, which represents the outcome of the test. An example can be run only once. An exception is raised if an attempt is made to run it more than once.
Indicates that the component references a type or method.
Creates the JSON representation of the example, which is just its name.
String representation of the example. This consists of the groups the example is in and the description. The string can be given to end-users to identify the example.