abstract class Spectator::Example
Overview
Base class for all types of examples.
Concrete types must implement the #run_impl,
#what,
#instance, and
#source` methods.
Direct Known Subclasses
Defined in:
spectator/example.crConstructors
-
.new(group : Spectator::ExampleGroup, sample_values : Internals::SampleValues)
Creates the base of the example.
Instance Method Summary
-
#[](index : Int) : Example
Retrieve the current example.
-
#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.
-
#instance
Retrieves the internal wrapped instance.
-
#run : Result
Runs the example code.
-
#source : Source
Source where the example originated from.
-
#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
[],
example_count : Int
example_count,
finished? : Bool
finished?,
symbolic? : Bool
symbolic?,
what : Symbol | String
what
Instance methods inherited from class Object
should(matcher : Spectator::Matchers::Matcher)
should,
should_not(matcher : Spectator::Matchers::Matcher)
should_not
Constructor Detail
Creates the base of the example. The group should be the example group the example belongs to. The sample_values are passed to the example code.
Instance Method Detail
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.
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.