mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Get rid of #add_examples
Added #example_count method to help with array sizing.
This commit is contained in:
parent
8b8981494d
commit
007572f0b8
2 changed files with 21 additions and 15 deletions
|
@ -30,9 +30,21 @@ module Spectator
|
|||
@children.select { |child| child.is_a?(ExampleGroup) }.map { |child| child.unsafe_as(ExampleGroup) }
|
||||
end
|
||||
|
||||
def example_count
|
||||
@children.sum do |child|
|
||||
child.is_a?(ExampleFactory) ? 1 : child.example_count
|
||||
end
|
||||
end
|
||||
|
||||
def all_examples
|
||||
Array(Example).new.tap do |array|
|
||||
add_examples(array)
|
||||
Array(Example).new(example_count).tap do |array|
|
||||
@children.each do |child|
|
||||
if child.is_a?(ExampleFactory)
|
||||
array << child.build
|
||||
else
|
||||
array.concat(child.all_examples)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -94,15 +106,5 @@ module Spectator
|
|||
private def wrap_proc(inner : Proc(Nil) ->, wrapper : ->)
|
||||
-> { inner.call(wrapper) }
|
||||
end
|
||||
|
||||
def add_examples(array : Array(Example))
|
||||
@children.each do |child|
|
||||
if child.is_a?(ExampleFactory)
|
||||
array << child.build
|
||||
else
|
||||
array.concat(child.all_examples)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,9 +8,13 @@ module Spectator
|
|||
super(what, parent)
|
||||
end
|
||||
|
||||
protected def add_examples(array : Array(Example))
|
||||
@collection.each do |value|
|
||||
examples = super.all_examples
|
||||
def example_count
|
||||
super.example_count * @collection.size
|
||||
end
|
||||
|
||||
def all_examples
|
||||
Array(Example).new(example_count).tap do |array|
|
||||
examples = super
|
||||
examples.each do |example|
|
||||
@mapping[example] = value
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue