From 4906dfae0d6b4f634eccbc10b69a44598a6ac9ae Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Fri, 4 Nov 2022 16:55:31 -0600 Subject: [PATCH] Add short before/after hook name --- src/spectator/dsl/hooks.cr | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/spectator/dsl/hooks.cr b/src/spectator/dsl/hooks.cr index 3cd4d87..6672e59 100644 --- a/src/spectator/dsl/hooks.cr +++ b/src/spectator/dsl/hooks.cr @@ -124,11 +124,21 @@ module Spectator::DSL # This means that values defined by `let` and `subject` are available. define_example_hook :before_each + # :ditto: + macro before(&block) + before_each {{block}} + end + # Defines a block of code that will be invoked after every example in the group. # The block will be run in the context of the current running example. # This means that values defined by `let` and `subject` are available. define_example_hook :after_each + # :ditto: + macro after(&block) + after_each {{block}} + end + # Defines a block of code that will be invoked around every example in the group. # The block will be run in the context of the current running example. # This means that values defined by `let` and `subject` are available. @@ -139,6 +149,11 @@ module Spectator::DSL # More code can run afterwards (in the block). define_example_hook :around_each + # :ditto: + macro around(&block) + around_each {{block}} + end + # Defines a block of code that will be invoked before every example in the group. # The block will be run in the context of the current running example. # This means that values defined by `let` and `subject` are available.