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)
end
# Indicates there is only one example to run.
def example_count
1
end
# String representation of the example.
# This consists of the groups the example is in and the description.
# 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.
abstract def finished? : Bool
# The number of examples in this instance.
abstract def example_count : Int
end
end

View File

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