diff --git a/src/spectator/runner.cr b/src/spectator/runner.cr index ad3e50d..21802f0 100644 --- a/src/spectator/runner.cr +++ b/src/spectator/runner.cr @@ -42,10 +42,8 @@ module Spectator # The order of examples is randomized # if specified by the configuration. private def example_order - if @config.randomize? - @suite.to_a.shuffle!(@config.random) - else - @suite.each + @suite.to_a.tap do |examples| + examples.shuffle!(@config.random) if @config.randomize? end end diff --git a/src/spectator/test_suite.cr b/src/spectator/test_suite.cr index 6392872..9712173 100644 --- a/src/spectator/test_suite.cr +++ b/src/spectator/test_suite.cr @@ -3,7 +3,6 @@ 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. @@ -12,13 +11,13 @@ module Spectator # Yields each example in the test suite. def each : Nil - each.each do |example| + iterator.each do |example| yield example end end - # Returns an iterator that yields all examples in the test suite. - def each : Iterator(Example) + # Creates an iterator for the example group. + private def iterator ExampleIterator.new(@group) end end