lib/cucumber/formatter/pretty.rb in kosmas58-cucumber-0.2.3.3 vs lib/cucumber/formatter/pretty.rb in kosmas58-cucumber-0.3.9.4

- old
+ new

@@ -16,20 +16,21 @@ def initialize(step_mother, io, options, delim='|') super(step_mother) @io = io @options = options @delim = delim - @indent = 0 @exceptions = [] + @indent = 0 end def visit_features(features) super - print_summary unless @options[:autoformat] + print_summary(features) unless @options[:autoformat] end def visit_feature(feature) + @exceptions = [] @indent = 0 if @options[:autoformat] file = File.join(@options[:autoformat], feature.file) dir = File.dirname(file) mkdir_p(dir) unless File.directory?(dir) @@ -74,17 +75,19 @@ @io.flush end def visit_feature_element(feature_element) @indent = 2 + @scenario_indent = 2 super @io.puts @io.flush end def visit_background(background) @indent = 2 + @scenario_indent = 2 @in_background = true super @in_background = nil @io.puts @io.flush @@ -93,27 +96,33 @@ def visit_background_name(keyword, name, file_colon_line, source_indent) visit_feature_element_name(keyword, name, file_colon_line, source_indent) end def visit_examples_name(keyword, name) - @io.puts("\n #{keyword} #{name}") + names = name.empty? ? [name] : name.split("\n") + @io.puts("\n #{keyword} #{names[0]}") + names[1..-1].each {|s| @io.puts " #{s}" } @io.flush - @indent = 4 + @indent = 6 + @scenario_indent = 6 end def visit_scenario_name(keyword, name, file_colon_line, source_indent) visit_feature_element_name(keyword, name, file_colon_line, source_indent) end def visit_feature_element_name(keyword, name, file_colon_line, source_indent) - line = " #{keyword} #{name}" + @io.puts if @scenario_indent == 6 + names = name.empty? ? [name] : name.split("\n") + line = "#{keyword} #{names[0]}".indent(@scenario_indent) @io.print(line) if @options[:source] line_comment = " # #{file_colon_line}".indent(source_indent) @io.print(format_string(line_comment, :comment)) end @io.puts + names[1..-1].each {|s| @io.puts " #{s}"} @io.flush end def visit_step(step) @indent = 6 @@ -124,23 +133,18 @@ if exception return if @exceptions.index(exception) @exceptions << exception end return if status != :failed && @in_background ^ background - - # @step_matches ||= [] - # return if @step_matches.index(step_match) - # @step_matches << step_match - @status = status super end def visit_step_name(keyword, step_match, status, source_indent, background) source_indent = nil unless @options[:source] formatted_step_name = format_step(keyword, step_match, status, source_indent) - @io.puts(" " + formatted_step_name) + @io.puts(formatted_step_name.indent(@scenario_indent + 2)) end def visit_multiline_arg(multiline_arg) return if @options[:no_multiline] super @@ -167,18 +171,19 @@ @io.flush end def visit_table_cell_value(value, width, status) status ||= @status || :passed - @io.print(' ' + format_string((value.to_s || '').ljust(width), status) + " #{@delim}") + @io.print(' ' + format_string((value.to_s || '').ljust(width), status) + ::Term::ANSIColor.reset(" #{@delim}")) @io.flush end private - def print_summary - print_counts + def print_summary(features) + print_stats(features) print_snippets(@options) + print_passing_wip(@options) end end end end