Class: GreenPepper::FreeTextWriter

Inherits:
Object
  • Object
show all
Includes:
KeywordFormat
Defined in:
lib/greenpepper/writer/freetextwriter.rb

Instance Method Summary collapse

Methods included from KeywordFormat

#error, #green_highlight, #grey_highlight, #highlight, #indent, #indent2, #newline, #red_highlight, #yellow_highlight

Instance Method Details

#example_to_html(ex, results) ⇒ Object

Visible for testing



36
37
38
39
40
41
42
# File 'lib/greenpepper/writer/freetextwriter.rb', line 36

def example_to_html(ex, results)
  res = newline(results[0].write(nil))
  results[1..-1].each_with_index{ |result, index|
    res += indent(result.write(ex.actions[index]))
  }
  res
end

#support?(execution_unit) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/greenpepper/writer/freetextwriter.rb', line 18

def support? execution_unit 
  execution_unit.result.is_a? FreeTextExecutionResults 
end

#write(html_doc, execution_units, write_options = {}) ⇒ Object

Write the results Returns a string of the document



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/greenpepper/writer/freetextwriter.rb', line 23

def write(html_doc, execution_units, write_options ={})
  
  html_results = []
  execution_units.each{ |unit|
      html_results << example_to_html(unit.example, unit.result)
  }

  # Use the parser to replace the old scenario with the new one
  parser = FreeTextParser.new
  parser.replace_scenarios html_doc, html_results
end