Add symbol for getting local from #given

This commit is contained in:
Michael Miller 2018-09-23 14:45:36 -06:00
parent 3c31783fd7
commit 56ae92a25d
2 changed files with 4 additions and 3 deletions

View file

@ -4,7 +4,7 @@ module Spectator
module DSL
class GivenExampleGroupBuilder < ExampleGroupBuilder
def initialize(what : String, @collection : Array(ValueWrapper))
def initialize(what : String, @collection : Array(ValueWrapper), @symbol : Symbol)
super(what)
end
@ -12,7 +12,7 @@ module Spectator
ExampleGroup.new(@what, parent).tap do |group|
children = [] of ExampleGroup::Child
@collection.each do |value|
iter_locals = locals.merge({:TODO => value})
iter_locals = locals.merge({@symbol => value})
iter_children = @children.map do |child|
child.build(group, iter_locals)
end

View file

@ -59,7 +59,8 @@ module Spectator
::Spectator::DSL::Builder.start_given_group(
{{collection.stringify}},
%to_a
%to_a,
:%group
)
{{block.body}}