lib/cucumber/formatter/pretty.rb in kosmas58-cucumber-0.3.11.6 vs lib/cucumber/formatter/pretty.rb in kosmas58-cucumber-0.3.90
- old
+ new
@@ -11,17 +11,17 @@
class Pretty < Ast::Visitor
include FileUtils
include Console
attr_writer :indent
- def initialize(step_mother, io, options, delim='|')
+ def initialize(step_mother, io, options)
super(step_mother)
@io = io
@options = options
- @delim = delim
@exceptions = []
@indent = 0
+ @prefixes = options[:prefixes] || {}
end
def visit_features(features)
super
print_summary(features) unless @options[:autoformat]
@@ -143,20 +143,22 @@
@io.puts(formatted_step_name.indent(@scenario_indent + 2))
end
def visit_multiline_arg(multiline_arg)
return if @options[:no_multiline]
+ @table = multiline_arg
super
end
def visit_exception(exception, status)
print_exception(exception, status, @indent)
@io.flush
end
def visit_table_row(table_row)
- @io.print @delim.indent(@indent)
+ @col_index = 0
+ @io.print ' |'.indent(@indent-2)
super
@io.puts
if table_row.exception && !@exceptions.index(table_row.exception)
print_exception(table_row.exception, :failed, @indent)
end
@@ -167,16 +169,29 @@
s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
@io.puts(format_string(s, @status))
@io.flush
end
- def visit_table_cell_value(value, width, status)
+ def visit_table_cell(cell)
+ super
+ @col_index += 1
+ end
+
+ def visit_table_cell_value(value, status)
status ||= @status || :passed
- @io.print(' ' + format_string((value.to_s || '').ljust(width), status) + ::Term::ANSIColor.reset(" #{@delim}"))
+ width = @table.col_width(@col_index)
+ cell_text = value.to_s || ''
+ padded = cell_text + (' ' * (width - cell_text.jlength))
+ prefix = cell_prefix(status)
+ @io.print(' ' + format_string("#{prefix}#{padded}", status) + ::Term::ANSIColor.reset(" |"))
@io.flush
end
private
+
+ def cell_prefix(status)
+ @prefixes[status]
+ end
def print_summary(features)
print_stats(features)
print_snippets(@options)
print_passing_wip(@options)