Class: QED::Reporter::Html

Inherits:
Abstract show all
Defined in:
lib/qed/reporter/html.rb

Overview

Html Reporter

FIXME: This must be completely redesigned since we moved back to text based evaluation –which makes generting HTML with modifications from the evaluation tricky. But I’ve come up with a farily clever way to handle this. Take the original and use Tilt to translate it into HTML, then take the evaluation results for code steps and use it to search the HTML for “the closest match”. Find the <pre> tag associated with the text and add class and color style. Of course the tricky part is the matching, but if we run the text snippet through Tilt as well we should be able to get an exact match. It won’t be fast, but it should work.

Instance Attribute Summary

Attributes inherited from Abstract

#io, #record, #session

Instance Method Summary collapse

Methods inherited from Abstract

After, Before, When, #after_code, #after_data, #after_demo, #after_desc, #after_head, #after_session, #after_step, #before_code, #before_data, #before_demo, #before_desc, #before_head, #before_session, #before_step, #code, #count_code, #count_demo, #count_desc, #count_error, #count_fail, #count_pass, #data, #demo, #demos, #desc, #errors, #fails, #head, #import, #load, #omits, #passes, #steps, #trace?, #unload, #update, #when

Constructor Details

#initialize(*args) ⇒ Html

Returns a new instance of Html.



24
25
26
# File 'lib/qed/reporter/html.rb', line 24

def initialize(*args)
  raise "HTML format is not currently working"
end

Instance Method Details

#after_document(demo) ⇒ Object



64
65
66
# File 'lib/qed/reporter/html.rb', line 64

def after_document(demo)
  io.puts demo.document.to_s
end

#error(step, exception) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/qed/reporter/html.rb', line 48

def error(step, exception)
  raise exception if $DEBUG

  step['class'] = 'error'          # TODO add class not replace
  step['style'] = 'color: red;'    # TODO add style not replace

  msg = "\n"
  msg << "  ##### ERROR #####\n"
  msg << "  # " + exception.to_s + "\n"
  msg << "  # " + exception.backtrace[0]
  msg << "\n"

  step.add_child(Nokogiri::HTML.fragment(msg))
end

#fail(step, assertion) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/qed/reporter/html.rb', line 35

def fail(step, assertion)
  step['class'] = 'fail'           # TODO add class not replace
  step['style'] = 'color: red;'    # TODO add style not replace

  msg = "\n"
  msg << "  ##### FAIL #####\n"
  msg << "  # " + assertion.to_s
  msg << "\n"

  step.add_child(Nokogiri::HTML.fragment(msg))
end

#pass(step) ⇒ Object



29
30
31
32
# File 'lib/qed/reporter/html.rb', line 29

def pass(step)
  step['class'] = 'pass'           # TODO add class not replace
  step['style'] = 'color: green;'  # TODO add style not replace
end