Use label in sub-group name

This commit is contained in:
Michael Miller 2019-09-26 15:05:28 -06:00
parent c3ea34e762
commit 1f300a4a18
2 changed files with 3 additions and 3 deletions

View file

@ -38,7 +38,7 @@ module Spectator
end
class Context%sample < {{@type.id}}
::Spectator::SpecBuilder.start_sample_group({{collection.stringify}}, :%sample) do |values|
::Spectator::SpecBuilder.start_sample_group({{collection.stringify}}, :%sample, {{block_arg.stringify}}) do |values|
sample = {{@type.id}}.new(values)
sample.%to_a
end

View file

@ -2,7 +2,7 @@ require "./nested_example_group_builder"
module Spectator::SpecBuilder
class SampleExampleGroupBuilder(T) < NestedExampleGroupBuilder
def initialize(what : String | Symbol, @id : Symbol, @collection_builder : TestValues -> Array(T))
def initialize(what : String | Symbol, @id : Symbol, @label : String, @collection_builder : TestValues -> Array(T))
super(what)
end
@ -20,7 +20,7 @@ module Spectator::SpecBuilder
private def build_sub_group(parent_group, element)
values = parent_group.context.values.add(@id, @what.to_s, element)
context = TestContext.new(parent_group.context, ExampleHooks.empty, values)
NestedExampleGroup.new(element.inspect, parent_group, context).tap do |group|
NestedExampleGroup.new("#{@label} = #{element.inspect}", parent_group, context).tap do |group|
group.children = children.map do |child|
child.build(group).as(ExampleComponent)
end