mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fetch iteration item from group
This commit is contained in:
parent
c79cb62a61
commit
d8e9d3128a
2 changed files with 10 additions and 0 deletions
|
@ -136,6 +136,14 @@ module Spectator::DSL
|
|||
{{collection}}
|
||||
end
|
||||
|
||||
{% if block.args.size == 1 %}
|
||||
let({{block.args.first}}) do |example|
|
||||
example.group.as(::Spectator::ExampleGroupIteration(typeof(Group%group.%collection.first))).item
|
||||
end
|
||||
{% elsif block.args.size > 1 %}
|
||||
{% raise "Expected 1 argument for 'sample' block, but got #{block.args.size}" %}
|
||||
{% end %}
|
||||
|
||||
::Spectator::DSL::Builder.start_iterative_group(
|
||||
%collection,
|
||||
::Spectator::Location.new({{block.filename}}, {{block.line_number}}),
|
||||
|
|
|
@ -2,6 +2,8 @@ require "./example_group"
|
|||
|
||||
module Spectator
|
||||
class ExampleGroupIteration(T) < ExampleGroup
|
||||
getter item : T
|
||||
|
||||
def initialize(@item : T, name : Label = nil, location : Location? = nil,
|
||||
group : ExampleGroup? = nil, metadata : Metadata = Metadata.new)
|
||||
super(name, location, group, metadata)
|
||||
|
|
Loading…
Reference in a new issue