Remove ExampleGroup#all_examples

Implement the same functionality with ExampleIterator.
This commit is contained in:
Michael Miller 2018-11-13 10:08:37 -07:00
parent b5a18ad324
commit 6c882f9cae
3 changed files with 5 additions and 15 deletions

View file

@ -50,19 +50,6 @@ module Spectator
end
end
# TODO: Remove this method.
def all_examples
Array(Example).new(example_count).tap do |array|
children.each do |child|
if child.is_a?(Example)
array << child
else
array.concat(child.as(ExampleGroup).all_examples)
end
end
end
end
def finished? : Bool
children.all?(&.finished?)
end

View file

@ -33,3 +33,5 @@ require "./successful_result"
require "./pending_result"
require "./failed_result"
require "./errored_result"
require "./example_iterator"

View file

@ -5,15 +5,16 @@ module Spectator
end
def run : Nil
iterator = ExampleIterator.new(@group)
results = [] of Result
elapsed = Time.measure do
@formatter.start_suite
results = @group.all_examples.map do |example|
results = iterator.map do |example|
@formatter.start_example(example)
Internals::Harness.run(example).tap do |result|
@formatter.end_example(result)
end.as(Result)
end
end.to_a
end
@formatter.end_suite(TestResults.new(results, elapsed))
end