Skip to content

Commit

Permalink
Add before and after as shorter variants
Browse files Browse the repository at this point in the history
  • Loading branch information
icy-arctic-fox committed Jun 24, 2024
1 parent 4031c6b commit 2917ebc
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/spectator/core/hooks.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ module Spectator::Core
hooks << ExampleHook(Example).new(&block)
end

def before(&block : Example ->) : Nil
before_each(&block)
end

def after_each(&block : Example ->)
hooks = @after_each ||= [] of ExampleHook(Example)
hooks << ExampleHook(Example).new(&block)
end

def after(&block : Example ->) : Nil
after_each(&block)
end

def before_all(&block : ->)
hooks = @before_all ||= [] of ContextHook
hooks << ContextHook.new(&block)
Expand Down

0 comments on commit 2917ebc

Please sign in to comment.