Class: Cucumber::Formatter::Html

Inherits:
Ast::Visitor show all
Defined in:
lib/cucumber/formatter/html.rb

Instance Attribute Summary

Attributes inherited from Ast::Visitor

#options

Instance Method Summary collapse

Methods inherited from Ast::Visitor

#current_feature_lines, #current_feature_lines=, #new_world, #step_definition, #visit_comment, #visit_comment_line, #visit_examples, #visit_py_string, #visit_step, #visit_table_cell, #visit_tag_name, #visit_tags, #world

Constructor Details

#initialize(step_mother, io, options) ⇒ Html

Returns a new instance of Html.



11
12
13
14
# File 'lib/cucumber/formatter/html.rb', line 11

def initialize(step_mother, io, options)
  super(step_mother)
  @builder = Builder::XmlMarkup.new(:target => io, :indent => 2)
end

Instance Method Details

#announce(announcement) ⇒ Object



116
117
118
# File 'lib/cucumber/formatter/html.rb', line 116

def announce(announcement)
  @builder.pre(announcement, :class => 'announcement')
end

#visit_background(background) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/cucumber/formatter/html.rb', line 55

def visit_background(background)
  @builder.div(:class => 'background') do
    @builder.ol do
      super
    end
  end
end

#visit_examples_name(keyword, name) ⇒ Object



80
81
82
# File 'lib/cucumber/formatter/html.rb', line 80

def visit_examples_name(keyword, name)
  @builder.h4("#{keyword} #{name}")
end

#visit_feature(feature) ⇒ Object



38
39
40
41
42
# File 'lib/cucumber/formatter/html.rb', line 38

def visit_feature(feature)
  @builder.div(:class => 'feature') do
    super
  end
end

#visit_feature_element(feature_element) ⇒ Object



63
64
65
66
67
68
# File 'lib/cucumber/formatter/html.rb', line 63

def visit_feature_element(feature_element)
  @builder.div(:class => 'scenario') do
    super
  end
  @open_step_list = true
end

#visit_feature_name(name) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/cucumber/formatter/html.rb', line 44

def visit_feature_name(name)
  lines = name.split(/\r?\n/)
  @builder.h2(lines[0])
  @builder.p do
    lines[1..-1].each do |line|
      @builder.text!(line.strip)
      @builder.br
    end
  end
end

#visit_features(features) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cucumber/formatter/html.rb', line 16

def visit_features(features)
  # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  @builder.declare!(
    :DOCTYPE,
    :html, 
    :PUBLIC, 
    '-//W3C//DTD XHTML 1.0 Strict//EN', 
    'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
  )
  @builder.html(:xmlns => 'http://www.w3.org/1999/xhtml') do
    @builder.head do
      @builder.title 'Cucumber'
      inline_css
    end
    @builder.body do
      @builder.div(:class => 'cucumber') do
        super
      end
    end
  end
end

#visit_multiline_arg(multiline_arg, status) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/cucumber/formatter/html.rb', line 94

def visit_multiline_arg(multiline_arg, status)
  if Ast::Table === multiline_arg
    @builder.table do
      super(multiline_arg, status)
    end
  else
    @builder.p do
      super(multiline_arg, status)
    end
  end
end

#visit_outline_table(outline_table) ⇒ Object



74
75
76
77
78
# File 'lib/cucumber/formatter/html.rb', line 74

def visit_outline_table(outline_table)
  @builder.table do
    super(outline_table)
  end
end

#visit_scenario_name(keyword, name, file_line, source_indent) ⇒ Object



70
71
72
# File 'lib/cucumber/formatter/html.rb', line 70

def visit_scenario_name(keyword, name, file_line, source_indent)
  @builder.h3("#{keyword} #{name}")
end

#visit_step_name(keyword, step_name, status, step_definition, source_indent) ⇒ Object



90
91
92
# File 'lib/cucumber/formatter/html.rb', line 90

def visit_step_name(keyword, step_name, status, step_definition, source_indent)
  @builder.li("#{keyword} #{step_name}", :class => status)
end

#visit_steps(scenarios) ⇒ Object



84
85
86
87
88
# File 'lib/cucumber/formatter/html.rb', line 84

def visit_steps(scenarios)
  @builder.ol do
    super
  end
end

#visit_table_cell_value(value, width, status) ⇒ Object



112
113
114
# File 'lib/cucumber/formatter/html.rb', line 112

def visit_table_cell_value(value, width, status)
  @builder.td(value, :class => status)
end

#visit_table_row(table_row, status) ⇒ Object



106
107
108
109
110
# File 'lib/cucumber/formatter/html.rb', line 106

def visit_table_row(table_row, status)
  @builder.tr do
    super(table_row, status)
  end
end