require 'erb' require 'spec/runner/formatter/base_text_formatter' module Spec module Runner module Formatter class HtmlFormatter < BaseTextFormatter include ERB::Util # for the #h method def initialize(options, output) super @example_group_number = 0 @example_number = 0 end def method_missing(sym, *args) # no-op end # The number of the currently running example_group def example_group_number @example_group_number end # The number of the currently running example (a global counter) def example_number @example_number end def start(example_count) @example_count = example_count @output.puts html_header @output.puts report_header @output.flush end def add_example_group(example_group) super @example_group_red = false @example_group_red = false @example_group_number += 1 unless example_group_number == 1 @output.puts " " @output.puts "" end @output.puts "
#{format_backtrace(failure.exception.backtrace)}
#{@snippet_extractor.snippet(failure.exception)}
"
end
def move_progress
@output.puts " "
@output.flush
end
def percent_done
result = 100.0
if @example_count != 0
result = ((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0
end
result
end
def dump_failure(counter, failure)
end
def dump_summary(duration, example_count, failure_count, pending_count)
if dry_run?
totals = "This was a dry-run"
else
totals = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}"
totals << ", #{pending_count} pending" if pending_count > 0
end
@output.puts ""
@output.puts ""
@output.puts ""
@output.puts ""
@output.puts "