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.cr

Constructors

Instance Method Summary

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

def self.new(group : Spectator::ExampleGroup, test_wrapper : Spectator::TestWrapper) #

Creates the base of the example. The group should be the example group the example belongs to.


[View source]

Instance Method Detail

def [](index : Int) : Example #

Retrieve the current example.


[View source]
def description : String | Symbol #
Description copied from class Spectator::ExampleComponent

Text that describes the context or test.


[View source]
def example_count : Int #

Indicates there is only one example to run.


[View source]
def finished? : Bool #

Indicates whether the example has already been run.


[View source]
def group : ExampleGroup #

Group that the example belongs to.


[View source]
def run : Result #

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.


[View source]
abstract def run_impl #

[View source]
def source : Source #

Source where the example originated from.


[View source]
def symbolic? : Bool #
Description copied from class Spectator::ExampleComponent

Indicates that the component references a type or method.


[View source]
def to_json(json : JSON::Builder) #

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


[View source]
def to_s(io) #

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.


[View source]