class Spectator::ExampleHooks

Overview

Collection of hooks that run at various times throughout testing. A hook is just a Proc (code block) that runs at a specified time.

Defined in:

spectator/example_hooks.cr

Constructors

Class Method Summary

Instance Method Summary

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(before_all : Array( -> ), before_each : Array(TestMetaMethod), after_all : Array( -> ), after_each : Array(TestMetaMethod), around_each : Array(SpectatorTest, Proc(Nil) -> )) #

Creates a new set of hooks.


[View source]

Class Method Detail

def self.empty #

Creates an empty set of hooks. This will effectively run nothing extra while running a test.


[View source]

Instance Method Detail

def run_after_all #

Runs all "after-all" hooks. These hooks should be run once after all examples in group finish.


[View source]
def run_after_each(wrapper : TestWrapper, example : Example) #

Runs all "after-all" hooks. These hooks should be run every time after each example in a group.


[View source]
def run_before_all #

Runs all "before-all" hooks. These hooks should be run once before all examples in the group start.


[View source]
def run_before_each(wrapper : TestWrapper, example : Example) #

Runs all "before-each" hooks. These hooks should be run every time before each example in a group.


[View source]
def wrap_around_each(test, block : -> ) #

Creates a proc that runs the "around-each" hooks in addition to a block passed to this method. To call the block and all "around-each" hooks, just invoke Proc#call on the returned proc.


[View source]