mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Method for creating groups of spy examples
This commit is contained in:
parent
5af9799df0
commit
50bc1af816
1 changed files with 14 additions and 0 deletions
|
@ -42,4 +42,18 @@ class SpyExample < Spectator::RunnableExample
|
|||
example.block = block
|
||||
end
|
||||
end
|
||||
|
||||
# Creates a group of spy examples.
|
||||
# Specify the number of examplese to create and a block to invoke when the example is run.
|
||||
# The block is given the index of the example in the group.
|
||||
def self.create_group(count, &block : Int32 -> Nil)
|
||||
values = Spectator::Internals::SampleValues.empty
|
||||
Spectator::RootExampleGroup.new(Spectator::ExampleHooks.empty, Spectator::ExampleConditions.empty).tap do |group|
|
||||
group.children = Array.new(count) do |index|
|
||||
new(group, values).tap do |example|
|
||||
example.block = block.partial(index)
|
||||
end.as(Spectator::ExampleComponent)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue