mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Explicit "provided" block description
Implements https://gitlab.com/arctic-fox/spectator/-/issues/69
This commit is contained in:
parent
01f9499828
commit
315a318d7d
2 changed files with 17 additions and 4 deletions
|
@ -14,8 +14,9 @@ module Spectator::DSL
|
|||
# Tags and metadata cannot be used with this macro.
|
||||
#
|
||||
# ```
|
||||
# given x = 42 do
|
||||
# provided x = 42, y: 123 do
|
||||
# expect(x).to eq(42)
|
||||
# expect(y).to eq(123)
|
||||
# end
|
||||
# ```
|
||||
macro provided(*assignments, **kwargs, &block)
|
||||
|
@ -26,13 +27,21 @@ module Spectator::DSL
|
|||
let({{assignment.target}}) { {{assignment.value}} }
|
||||
{% end %}
|
||||
{% for name, value in kwargs %}
|
||||
let({{name}}) { {{value}} }
|
||||
{% if name != :it %}let({{name}}) { {{value}} }{% end %}
|
||||
{% end %}
|
||||
|
||||
{% if block %}
|
||||
example {{block}}
|
||||
{% if description = kwargs[:it] %}
|
||||
example {{description}} {{block}}
|
||||
{% else %}
|
||||
example {{block}}
|
||||
{% end %}
|
||||
{% else %}
|
||||
example {{assignments.splat.stringify}}
|
||||
{% if description = kwargs[:it] %}
|
||||
example {{description}} {{block}}
|
||||
{% else %}
|
||||
example {{assignments.splat.stringify}}
|
||||
{% end %}
|
||||
{% end %}
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue