class

Spectator::ExampleHooks

Inherits Reference < Object

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

Constructors

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.

Source

Class methods

empty

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

Source

Instance methods

run_after_all

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

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

Source
run_before_all

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

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

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

Source