mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow named arguments in provided
block
This commit is contained in:
parent
ef1832721c
commit
9a97596b84
3 changed files with 62 additions and 3 deletions
|
@ -18,13 +18,16 @@ module Spectator::DSL
|
|||
# expect(x).to eq(42)
|
||||
# end
|
||||
# ```
|
||||
macro provided(*assignments, &block)
|
||||
macro provided(*assignments, **kwargs, &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}} }
|
||||
{% end %}
|
||||
{% for name, value in kwargs %}
|
||||
let({{name}}) { {{value}} }
|
||||
{% end %}
|
||||
|
||||
{% if block %}
|
||||
example {{block}}
|
||||
|
@ -36,9 +39,9 @@ module Spectator::DSL
|
|||
|
||||
# :ditto:
|
||||
@[Deprecated("Use `provided` instead.")]
|
||||
macro given(*assignments, &block)
|
||||
macro given(*assignments, **kwargs, &block)
|
||||
{% raise "Cannot use 'given' inside of a test block" if @def %}
|
||||
provided({{assignments.splat}}) {{block}}
|
||||
provided({{assignments.splat(",")}} {{kwargs.double_splat}}) {{block}}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue