Placeholder code for after hooks

This commit is contained in:
Michael Miller 2020-11-15 11:22:06 -07:00
parent 19d57dd828
commit 0279606a1c
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -27,9 +27,25 @@ module Spectator::DSL
end
macro after_all(&block)
{% raise "Cannot use 'after_all' inside of a test block" if @def %}
def self.%hook : Nil
{{block.body}}
end
::Spectator::DSL::Builder.after_all { {{@type.name}}.%hook }
end
macro after_each(&block)
{% raise "Cannot use 'after_each' inside of a test block" if @def %}
def %hook : Nil
{{block.body}}
end
::Spectator::DSL::Builder.after_each do |example|
example.with_context({{@type.name}}) { %hook }
end
end
end
end