require 'mspec/expectations/expectations' require 'mspec/runner/formatters/dotted' class HtmlFormatter < DottedFormatter def register super MSpec.register :start, self MSpec.register :enter, self MSpec.register :leave, self end def start print <<-EOH Spec Output For #{RUBY_NAME} (#{RUBY_VERSION}) EOH end def enter(describe) print "

#{describe}

\n\n
\n" end def exception(exception) super outcome = exception.failure? ? "FAILED" : "ERROR" print %[
  • - #{exception.it} (] print %[#{outcome} - #{@count})
  • \n] end def after(state) print %[
  • - #{state.it}
  • \n] unless exception? end def finish success = @exceptions.empty? unless success print "
    \n" print %[
      ] count = 0 @exceptions.each do |exc| outcome = exc.failure? ? "FAILED" : "ERROR" print %[\n
    1. #{escape(exc.description)} #{outcome}

      \n

      ] print escape(exc.message) print "

      \n
      \n"
              print escape(exc.backtrace)
              print "
      \n
    2. \n" end print "
    \n" end print %[

    #{@timer.format}

    \n] print %[

    #{@tally.format}

    \n] print "\n\n" end def escape(string) string.gsub("&", " ").gsub("<", "<").gsub(">", ">") end end