Parent

Included Modules

Class Index [+]

Quicksearch

Cucumber::Formatter::Pretty

The formatter used for --format pretty (the default formatter).

This formatter prints features to plain text - exactly how they were parsed, just prettier. That means with proper indentation and alignment of table columns.

If the output is STDOUT (and not a file), there are bright colours to watch too.

Attributes

indent[W]
step_mother[R]

Public Class Methods

new(step_mother, path_or_io, options) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 23
23:       def initialize(step_mother, path_or_io, options)
24:         @step_mother, @io, @options = step_mother, ensure_io(path_or_io, "pretty"), options
25:         @exceptions = []
26:         @indent = 0
27:         @prefixes = options[:prefixes] || {}
28:         @delayed_announcements = []
29:       end

Public Instance Methods

after_background(background) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 87
87:       def after_background(background)
88:         @in_background = nil
89:         @io.puts
90:         @io.flush
91:       end
after_feature_element(feature_element) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 76
76:       def after_feature_element(feature_element)
77:         @io.puts
78:         @io.flush
79:       end
after_features(features) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 31
31:       def after_features(features)
32:         print_summary(features) unless @options[:autoformat]
33:       end
after_multiline_arg(multiline_arg) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 175
175:       def after_multiline_arg(multiline_arg)
176:         @table = nil
177:       end
after_outline_table(outline_table) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 118
118:       def after_outline_table(outline_table)
119:         @table = nil
120:         @indent = 4
121:       end
after_table_cell(cell) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 194
194:       def after_table_cell(cell)
195:         return unless @table
196:         @col_index += 1
197:       end
after_table_row(table_row) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 185
185:       def after_table_row(table_row)
186:         return if !@table || @hide_this_step
187:         print_table_row_announcements
188:         @io.puts
189:         if table_row.exception && !@exceptions.include?(table_row.exception)
190:           print_exception(table_row.exception, table_row.status, @indent)
191:         end
192:       end
after_tags(tags) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 51
51:       def after_tags(tags)
52:         if @indent == 1
53:           @io.puts
54:           @io.flush
55:         end
56:       end
background_name(keyword, name, file_colon_line, source_indent) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 93
93:       def background_name(keyword, name, file_colon_line, source_indent)        
94:         print_feature_element_name(keyword, name, file_colon_line, source_indent)
95:       end
before_background(background) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 81
81:       def before_background(background)
82:         @indent = 2
83:         @scenario_indent = 2
84:         @in_background = true
85:       end
before_examples_array(examples_array) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 97
 97:       def before_examples_array(examples_array)
 98:         @indent = 4
 99:         @io.puts
100:         @visiting_first_example_name = true
101:       end
before_feature(feature) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 35
35:       def before_feature(feature)
36:         @exceptions = []
37:         @indent = 0
38:         if @options[:autoformat]
39:           file = File.join(@options[:autoformat], feature.file)
40:           dir = File.dirname(file)
41:           mkdir_p(dir) unless File.directory?(dir)
42:           @io = ensure_file(file, "pretty")
43:         end
44:       end
before_feature_element(feature_element) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 71
71:       def before_feature_element(feature_element)
72:         @indent = 2
73:         @scenario_indent = 2
74:       end
before_multiline_arg(multiline_arg) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 170
170:       def before_multiline_arg(multiline_arg)
171:         return if @options[:no_multiline] || @hide_this_step
172:         @table = multiline_arg
173:       end
before_outline_table(outline_table) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 114
114:       def before_outline_table(outline_table)
115:         @table = outline_table
116:       end
before_step(step) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 127
127:       def before_step(step)
128:         @current_step = step
129:         @indent = 6
130:       end
before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 132
132:       def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
133:         @hide_this_step = false
134:         if exception
135:           if @exceptions.include?(exception)
136:             @hide_this_step = true
137:             return
138:           end
139:           @exceptions << exception
140:         end
141:         if status != :failed && @in_background ^ background
142:           @hide_this_step = true
143:           return
144:         end
145:         @status = status
146:       end
before_table_row(table_row) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 179
179:       def before_table_row(table_row)
180:         return if !@table || @hide_this_step
181:         @col_index = 0
182:         @io.print '  |'.indent(@indent-2)
183:       end
comment_line(comment_line) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 46
46:       def comment_line(comment_line)
47:         @io.puts(comment_line.indent(@indent))
48:         @io.flush
49:       end
examples_name(keyword, name) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 103
103:       def examples_name(keyword, name)
104:         puts unless @visiting_first_example_name
105:         @visiting_first_example_name = false
106:         names = name.strip.empty? ? [name.strip] : name.split("\n")
107:         @io.puts("    #{keyword}: #{names[0]}")
108:         names[1..1].each {|s| @io.puts "      #{s}" } unless names.empty?
109:         @io.flush
110:         @indent = 6
111:         @scenario_indent = 6
112:       end
exception(exception, status) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 164
164:       def exception(exception, status)
165:         return if @hide_this_step
166:         print_exception(exception, status, @indent)
167:         @io.flush
168:       end
feature_name(keyword, name) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 65
65:       def feature_name(keyword, name)
66:         @io.puts("#{keyword}: #{name}")
67:         @io.puts
68:         @io.flush
69:       end
py_string(string) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 156
156:       def py_string(string)
157:         return if @hide_this_step
158:         s = %{"""\n#{string}\n"""}.indent(@indent)
159:         s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
160:         @io.puts(format_string(s, @current_step.status))
161:         @io.flush
162:       end
scenario_name(keyword, name, file_colon_line, source_indent) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 123
123:       def scenario_name(keyword, name, file_colon_line, source_indent)
124:         print_feature_element_name(keyword, name, file_colon_line, source_indent)
125:       end
step_name(keyword, step_match, status, source_indent, background) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 148
148:       def step_name(keyword, step_match, status, source_indent, background)
149:         return if @hide_this_step
150:         source_indent = nil unless @options[:source]
151:         name_to_report = format_step(keyword, step_match, status, source_indent)
152:         @io.puts(name_to_report.indent(@scenario_indent + 2))
153:         print_announcements
154:       end
table_cell_value(value, status) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 199
199:       def table_cell_value(value, status)
200:         return if !@table || @hide_this_step
201:         status ||= @status || :passed
202:         width = @table.col_width(@col_index)
203:         cell_text = escape_cell(value.to_s || '')
204:         padded = cell_text + (' ' * (width - cell_text.unpack('U*').length))
205:         prefix = cell_prefix(status)
206:         @io.print(' ' + format_string("#{prefix}#{padded}", status) + ::Term::ANSIColor.reset(" |"))
207:         @io.flush
208:       end
tag_name(tag_name) click to toggle source
    # File lib/cucumber/formatter/pretty.rb, line 58
58:       def tag_name(tag_name)
59:         tag = format_string(tag_name, :tag).indent(@indent)
60:         @io.print(tag)
61:         @io.flush
62:         @indent = 1
63:       end

Private Instance Methods

cell_prefix(status) click to toggle source
     # File lib/cucumber/formatter/pretty.rb, line 226
226:       def cell_prefix(status)
227:         @prefixes[status]
228:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.