class Spectator::Harness
- Spectator::Harness
- Reference
- Object
Overview
Helper class that acts as a gateway between example code and the test framework.
Every example must be invoked by passing it to #run
.
This sets up the harness so that the example code can use it.
The test framework does the following:
result = Harness.run(example)
# Do something with the result.
Then from the example code, the harness can be accessed via #current
like so:
harness = ::Spectator::Harness.current
# Do something with the harness.
Of course, the end-user shouldn't see this or work directly with the harness. Instead, methods the user calls can access it. For instance, an expectation reporting a result.
Defined in:
spectator/harness.crConstructors
-
.current : self
Retrieves the harness for the current running example.
Class Method Summary
-
.current? : self | Nil
Retrieves the harness for the current running example.
-
.run(example : Example) : Result
Wraps an example with a harness and runs the example.
Instance Method Summary
-
#defer(&block : -> ) : Nil
Marks a block of code to run later.
-
#example : Example
Retrieves the current running example.
-
#expectations : Expectations::ExampleExpectations
Generates the reported expectations from the example.
-
#group
Retrieves the group for the current running example.
- #mocks : Mocks::Registry
-
#report_expectation(expectation : Expectations::Expectation) : Nil
Reports the outcome of an expectation.
-
#run_deferred : Nil
Runs all deferred blocks.
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
Class Method Detail
Wraps an example with a harness and runs the example.
The #current
harness will be set
prior to running the example, and reset after.
The example argument will be the example to run.
The result returned from Example#run
will be returned.
Instance Method Detail
Generates the reported expectations from the example. This should be run after the example has finished.
Reports the outcome of an expectation. An exception will be raised when a failing result is given.