From e51ad6d504d02603e9c5b6588e9dcd4ca9e851d7 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 12 Jun 2021 17:06:43 -0600 Subject: [PATCH] Check if `provided` and `given` are used in a method --- src/spectator/dsl/concise.cr | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/spectator/dsl/concise.cr b/src/spectator/dsl/concise.cr index 0fb13d2..bba29f2 100644 --- a/src/spectator/dsl/concise.cr +++ b/src/spectator/dsl/concise.cr @@ -19,6 +19,8 @@ module Spectator::DSL # end # ``` macro provided(*assignments, &block) + {% raise "Cannot use 'provided' inside of a test block" if @def %} + class Given%given < {{@type.id}} {% for assignment in assignments %} let({{assignment.target}}) { {{assignment.value}} } @@ -35,6 +37,7 @@ module Spectator::DSL # :ditto: @[Deprecated("Use `provided` instead.")] macro given(*assignments, &block) + {% raise "Cannot use 'given' inside of a test block" if @def %} provided({{assignments.splat}}) {{block}} end end