lib/cucumber/formatter/console.rb in cucumber-0.3.1 vs lib/cucumber/formatter/console.rb in cucumber-0.3.2

- old
+ new

@@ -49,21 +49,19 @@ @io.flush end end def print_counts - @io.puts dump_count(step_mother.scenarios.length, "scenario") + @io.print dump_count(step_mother.scenarios.length, "scenario") + print_status_counts{|status| step_mother.scenarios(status)} - [:failed, :skipped, :undefined, :pending, :passed].each do |status| - if step_mother.steps(status).any? - count_string = dump_count(step_mother.steps(status).length, "step", status.to_s) - @io.puts format_string(count_string, status) - @io.flush - end - end - end + @io.print dump_count(step_mother.steps.length, "step") + print_status_counts{|status| step_mother.steps(status)} + @io.flush + end + def print_exception(e, status, indent) if @options[:strict] || !(Undefined === e) || e.nested? @io.puts(format_string("#{e.message} (#{e.class})\n#{e.backtrace.join("\n")}".indent(indent), status)) end end @@ -92,9 +90,17 @@ @io.puts(format_string(announcement, :tag)) @io.flush end private + + def print_status_counts + counts = [:failed, :skipped, :undefined, :pending, :passed].map do |status| + elements = yield status + elements.any? ? format_string("#{elements.length} #{status.to_s}", status) : nil + end + @io.puts(" (#{counts.compact.join(', ')})") + end def dump_count(count, what, state=nil) [count, state, "#{what}#{count == 1 ? '' : 's'}"].compact.join(" ") end \ No newline at end of file