Prevent defining an example or group in a test

This commit is contained in:
Michael Miller 2020-09-26 19:23:57 -06:00
parent 99a9d7960a
commit 4567162459
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
2 changed files with 4 additions and 0 deletions

View file

@ -5,6 +5,8 @@ module Spectator::DSL
module Examples
macro define_example(name)
macro {{name.id}}(what = nil, &block)
\{% raise "Cannot use '{{name.id}}' inside of a test block" if @def %}
def %test
\{{block.body}}
end

View file

@ -11,6 +11,8 @@ module Spectator::DSL
#
# TODO: Handle string interpolation in example and group names.
macro {{name.id}}(what, &block)
\{% raise "Cannot use '{{name.id}}' inside of a test block" if @def %}
class Group%group < \{{@type.id}}
_spectator_group_subject(\{{what}})