Better implementation of explicit subject

This commit is contained in:
Michael Miller 2021-12-02 01:57:34 -07:00
parent 315a318d7d
commit d9269e17a8
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2

View file

@ -19,7 +19,7 @@ module Spectator::DSL
# expect(y).to eq(123)
# end
# ```
macro provided(*assignments, **kwargs, &block)
macro provided(*assignments, it description = nil, **kwargs, &block)
{% raise "Cannot use 'provided' inside of a test block" if @def %}
class Given%given < {{@type.id}}
@ -27,17 +27,17 @@ module Spectator::DSL
let({{assignment.target}}) { {{assignment.value}} }
{% end %}
{% for name, value in kwargs %}
{% if name != :it %}let({{name}}) { {{value}} }{% end %}
let({{name}}) { {{value}} }
{% end %}
{% if block %}
{% if description = kwargs[:it] %}
{% if description %}
example {{description}} {{block}}
{% else %}
example {{block}}
{% end %}
{% else %}
{% if description = kwargs[:it] %}
{% if description %}
example {{description}} {{block}}
{% else %}
example {{assignments.splat.stringify}}