mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
GivenExampleGroupBuilder produces group of groups
Now a group is created for each element in the collection. A group to contain the sub-groups is returned.
This commit is contained in:
parent
1c7c6e5e90
commit
ef7e0462cb
2 changed files with 21 additions and 8 deletions
|
@ -10,15 +10,18 @@ module Spectator
|
|||
|
||||
def build(parent : ExampleGroup?, sample_values : Internals::SampleValues) : ExampleGroup
|
||||
ExampleGroup.new(@what, parent, build_hooks).tap do |group|
|
||||
children = [] of ExampleGroup::Child
|
||||
@collection.each do |value|
|
||||
iter_values = sample_values.add(@symbol, @symbol.to_s, value)
|
||||
iter_children = @children.map do |child|
|
||||
child.build(group, iter_values)
|
||||
group.children = @collection.map do |value|
|
||||
build_sub_group(group, sample_values, value).as(ExampleGroup::Child)
|
||||
end
|
||||
children.concat(iter_children)
|
||||
end
|
||||
group.children = children
|
||||
end
|
||||
|
||||
private def build_sub_group(parent : ExampleGroup, sample_values : Internals::SampleValues, value : T) : ExampleGroup
|
||||
sub_values = sample_values.add(@symbol, @symbol.to_s, value)
|
||||
ExampleGroup.new(value.to_s, parent, ExampleHooks.empty).tap do |group|
|
||||
group.children = @children.map do |child|
|
||||
child.build(group, sub_values).as(ExampleGroup::Child)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,15 @@
|
|||
module Spectator
|
||||
class ExampleHooks
|
||||
def self.empty
|
||||
new(
|
||||
[] of ->,
|
||||
[] of ->,
|
||||
[] of ->,
|
||||
[] of ->,
|
||||
[] of Proc(Nil) ->
|
||||
)
|
||||
end
|
||||
|
||||
def initialize(
|
||||
@before_all : Array(->),
|
||||
@before_each : Array(->),
|
||||
|
|
Loading…
Reference in a new issue