From 837e4cb85dc974cc116aadbcc0bd6841382245bc Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Tue, 17 Aug 2021 12:54:36 -0600 Subject: [PATCH] Implement Indexable(Node) on ExampleGroup --- src/spectator/example_group.cr | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/spectator/example_group.cr b/src/spectator/example_group.cr index 3b174a2..1186ea0 100644 --- a/src/spectator/example_group.cr +++ b/src/spectator/example_group.cr @@ -5,9 +5,8 @@ require "./node" module Spectator # Collection of examples and sub-groups. class ExampleGroup < Node - include Enumerable(Node) include Hooks - include Iterable(Node) + include Indexable(Node) @nodes = [] of Node @@ -71,6 +70,8 @@ module Spectator group << self if group end + delegate size, unsafe_fetch, to: @nodes + # Creates a child that is attched to the group. # Yields zero or more times to create the child. # The group the child should be attached to is provided as a block argument. @@ -88,16 +89,6 @@ module Spectator @nodes.delete(node) end - # Yields each node (example and sub-group). - def each - @nodes.each { |node| yield node } - end - - # Returns an iterator for each (example and sub-group). - def each - @nodes.each - end - # Checks if all examples and sub-groups have finished. def finished? : Bool @nodes.all?(&.finished?)