Update Runner to not use Iterable#each
This commit is contained in:
Michael Miller 2019-03-25 11:29:20 -06:00
parent 3654b2473b
commit 49c396714e
2 changed files with 5 additions and 8 deletions

View file

@ -42,10 +42,8 @@ module Spectator
# The order of examples is randomized # The order of examples is randomized
# if specified by the configuration. # if specified by the configuration.
private def example_order private def example_order
if @config.randomize? @suite.to_a.tap do |examples|
@suite.to_a.shuffle!(@config.random) examples.shuffle!(@config.random) if @config.randomize?
else
@suite.each
end end
end end

View file

@ -3,7 +3,6 @@ module Spectator
# Use `#each` to enumerate over all tests in the suite. # Use `#each` to enumerate over all tests in the suite.
class TestSuite class TestSuite
include Enumerable(Example) include Enumerable(Example)
include Iterable(Example)
# Creates the test suite. # Creates the test suite.
# The example *group* provided will be run. # The example *group* provided will be run.
@ -12,13 +11,13 @@ module Spectator
# Yields each example in the test suite. # Yields each example in the test suite.
def each : Nil def each : Nil
each.each do |example| iterator.each do |example|
yield example yield example
end end
end end
# Returns an iterator that yields all examples in the test suite. # Creates an iterator for the example group.
def each : Iterator(Example) private def iterator
ExampleIterator.new(@group) ExampleIterator.new(@group)
end end
end end