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