Implement ExampleComponent#example_count

This commit is contained in:
Michael Miller 2018-10-14 18:37:54 -06:00
parent 467afd053c
commit eade6873e4
3 changed files with 10 additions and 5 deletions

View file

@ -29,6 +29,11 @@ module Spectator
def initialize(@group, sample_values : Internals::SampleValues) def initialize(@group, sample_values : Internals::SampleValues)
end end
# Indicates there is only one example to run.
def example_count
1
end
# String representation of the example. # String representation of the example.
# This consists of the groups the example is in and the description. # This consists of the groups the example is in and the description.
# The string can be given to end-users to identify the example. # The string can be given to end-users to identify the example.

View file

@ -7,5 +7,8 @@ module Spectator
# Indicates whether the example (or group) has been completely run. # Indicates whether the example (or group) has been completely run.
abstract def finished? : Bool abstract def finished? : Bool
# The number of examples in this instance.
abstract def example_count : Int
end end
end end

View file

@ -27,11 +27,8 @@ module Spectator
children.each children.each
end end
# TODO: Remove this method. def example_count : Int
def example_count children.sum(&.example_count)
children.sum do |child|
child.is_a?(Example) ? 1 : child.as(ExampleGroup).example_count
end
end end
# TODO: Remove this method. # TODO: Remove this method.