require 'erb' require 'rspec/core/formatters/base_text_formatter' module RSpec module Core module Formatters class HtmlFormatter < BaseTextFormatter include ERB::Util # for the #h method def method_missing(m, *a, &b) # no-op end def message(message) end def initialize(output) super(output) @example_group_number = 0 @example_number = 0 @header_red = nil 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) super(example_count) @output.puts html_header @output.puts report_header @output.flush end def example_group_started(example_group) super(example_group) @example_group_red = false @example_group_number += 1 unless example_group_number == 1 @output.puts " " @output.puts "" end @output.puts "
#{format_backtrace(exception.backtrace, example).join("\n")}
#{@snippet_extractor.snippet(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_failures
end
def dump_pending
end
def dump_summary(duration, example_count, failure_count, pending_count)
# TODO - kill dry_run?
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 "