Object
# File lib/gherkin/formatter/pretty_formatter.rb, line 29 def background(comments, keyword, name, description, line) @io.puts print_comments(comments, ' ') @io.puts " #{keyword}: #{name}#{indented_element_uri!(keyword, name, line)}" print_description(description, ' ') end
# File lib/gherkin/formatter/pretty_formatter.rb, line 48 def examples(comments, tags, keyword, name, description, line, examples_table) @io.puts print_comments(comments, ' ') print_tags(tags, ' ') @io.puts " #{keyword}: #{name}" print_description(description, ' ') table(examples_table) end
# File lib/gherkin/formatter/pretty_formatter.rb, line 21 def feature(comments, tags, keyword, name, description, uri) @uri = uri print_comments(comments, '') print_tags(tags, '') @io.puts "#{keyword}: #{name}" print_description(description, ' ', false) end
# File lib/gherkin/formatter/pretty_formatter.rb, line 36 def scenario(comments, tags, keyword, name, description, line) @io.puts print_comments(comments, ' ') print_tags(tags, ' ') @io.puts " #{keyword}: #{name}#{indented_element_uri!(keyword, name, line)}" print_description(description, ' ') end
# File lib/gherkin/formatter/pretty_formatter.rb, line 44 def scenario_outline(comments, tags, keyword, name, description, line) scenario(comments, tags, keyword, name, description, line) end
# File lib/gherkin/formatter/pretty_formatter.rb, line 57 def step(comments, keyword, name, line, multiline_arg, status, exception, arguments, stepdef_location) status_param = "#{status}_param" if status name = Gherkin::Formatter::Argument.format(name, @format, (arguments || [])) step = "#{keyword}#{name}" step = self.__send__(status, step, @monochrome) if status print_comments(comments, ' ') @io.puts(" #{step}#{indented_step_location!(stepdef_location)}") case multiline_arg when String py_string(multiline_arg) when Array table(multiline_arg) when NilClass else raise "Bad multiline_arg: #{multiline_arg.inspect}" end end
This method can be invoked before a scenario, to ensure location arguments are aligned
# File lib/gherkin/formatter/pretty_formatter.rb, line 85 def steps(steps) @step_lengths = steps.map {|keyword, name| (keyword+name).unpack("U*").length} @max_step_length = @step_lengths.max @step_index = -1 end
# File lib/gherkin/formatter/pretty_formatter.rb, line 77 def syntax_error(state, event, legal_events, line) raise "SYNTAX ERROR" end
# File lib/gherkin/formatter/pretty_formatter.rb, line 91 def table(rows) cell_lengths = rows.map do |row| row.cells.map do |cell| escape_cell(cell).unpack("U*").length end end max_lengths = cell_lengths.transpose.map { |col_lengths| col_lengths.max }.flatten rows.each_with_index do |row, i| row.comments.each do |comment| @io.puts " #{comment}" end j = -1 @io.puts ' | ' + row.cells.zip(max_lengths).map { |cell, max_length| j += 1 color(cell, nil, j) + ' ' * (max_length - cell_lengths[i][j]) }.join(' | ') + ' |' end end
Generated with the Darkfish Rdoc Generator 2.