Check if provided and given are used in a method

This commit is contained in:
Michael Miller 2021-06-12 17:06:43 -06:00
parent 04d6c70f59
commit e51ad6d504
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -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