Implement creation of hooks

This commit is contained in:
Michael Miller 2018-09-10 21:27:24 -06:00
parent 387e129a89
commit 2ff8ebb3cb
2 changed files with 15 additions and 10 deletions

View file

@ -4,6 +4,11 @@ module Spectator
class Context
getter examples = [] of Example
getter contexts = [] of Context
getter before_all_hooks = [] of ->
getter before_each_hooks = [] of ->
getter after_all_hooks = [] of ->
getter after_each_hooks = [] of ->
getter around_each_hooks = [] of Example ->
def all_examples
add_examples

View file

@ -139,24 +139,24 @@ module Spectator
end
end
def before_all
raise NotImplementedError.new("Spectator::DSL#before_all")
macro before_all(&block)
CURRENT_CONTEXT.before_all_hooks << -> {{block}}
end
def before_each
raise NotImplementedError.new("Spectator::DSL#before_each")
macro before_each(&block)
CURRENT_CONTEXT.before_each_hooks << -> {{block}}
end
def after_all
raise NotImplementedError.new("Spectator::DSL#after_all")
macro after_all(&block)
CURRENT_CONTEXT.after_all_hooks << -> {{block}}
end
def after_each
raise NotImplementedError.new("Spectator::DSL#after_each")
macro after_each(&block)
CURRENT_CONTEXT.after_each_hooks << -> {{block}}
end
def around_each
raise NotImplementedError.new("Spectator::DSL#around_each")
macro around_each(&block)
CURRENT_CONTEXT.around_each_hooks << -> {{block}}
end
def include_examples