Implement Iterable

This commit is contained in:
Michael Miller 2019-03-23 19:42:32 -06:00
parent d0ba2c5400
commit 29279e1812

View file

@ -3,6 +3,7 @@ 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.
@ -11,13 +12,13 @@ module Spectator
# Yields each example in the test suite. # Yields each example in the test suite.
def each : Nil def each : Nil
iterator.each do |example| each.each do |example|
yield example yield example
end end
end end
# Creates an iterator for the example group. # Returns an iterator that yields all examples in the test suite.
private def iterator def each : Iterator(Example)
ExampleIterator.new(@group) ExampleIterator.new(@group)
end end
end end