From 52a6a645b9a96bce2bc58d88307f029bb3680333 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sun, 3 Mar 2019 11:05:28 -0700 Subject: [PATCH] Display group names --- src/spectator/formatting/document_formatter.cr | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/spectator/formatting/document_formatter.cr b/src/spectator/formatting/document_formatter.cr index 9ad7d23..c591c16 100644 --- a/src/spectator/formatting/document_formatter.cr +++ b/src/spectator/formatting/document_formatter.cr @@ -15,11 +15,24 @@ module Spectator::Formatting # Does nothing when an example is started. def start_example(example) - # TODO: Display group names. + # TODO: Condense similar parents. + current_group = example.group + group_list = [] of NestedExampleGroup + while current_group.is_a?(NestedExampleGroup) + group_list << current_group + current_group = current_group.parent + end + indent = 0 + group_list.reverse_each do |group| + indent.times { @io.print ' ' } + @io.puts group.what + indent += 2 + end end # Produces a single character output based on a result. def end_example(result) + # TODO: Indent. @io.puts result.call(Color) { result.example.what } end end