background(background)
click to toggle source
def background(background)
replay
@statement = background
end
done()
click to toggle source
eof()
click to toggle source
examples(examples)
click to toggle source
def examples(examples)
replay
@io.puts
print_comments(examples.comments, ' ')
print_tags(examples.tags, ' ')
@io.puts " #{examples.keyword}: #{examples.name}"
print_description(examples.description, ' ')
table(examples.rows)
end
feature(feature)
click to toggle source
def feature(feature)
print_comments(feature.comments, '')
print_tags(feature.tags, '')
@io.puts "#{feature.keyword}: #{feature.name}"
print_description(feature.description, ' ', false)
end
match(match)
click to toggle source
def match(match)
@match = match
print_statement
print_step('executing', @match.arguments, @match.location, false)
end
print_statement()
click to toggle source
def print_statement
return if @statement.nil?
calculate_location_indentations
@io.puts
print_comments(@statement.comments, ' ')
print_tags(@statement.tags, ' ') if @statement.respond_to?(:tags)
@io.write " #{@statement.keyword}: #{@statement.name}"
location = @executing ? "#{@uri}:#{@statement.line}" : nil
@io.puts indented_location(location, true)
print_description(@statement.description, ' ')
@statement = nil
end
print_step(status, arguments, location, proceed)
click to toggle source
def print_step(status, arguments, location, proceed)
step = proceed ? @steps.shift : @steps[0]
text_format = format(status)
arg_format = arg_format(status)
print_comments(step.comments, ' ')
@io.write(' ')
@io.write(text_format.text(step.keyword))
@step_printer.write_step(@io, text_format, arg_format, step.name, arguments)
@io.puts(indented_location(location, proceed))
doc_string(step.doc_string) if step.doc_string
table(step.rows) if step.rows
end
print_steps()
click to toggle source
def print_steps
while(@steps.any?)
print_step('skipped', [], nil, true)
end
end
replay()
click to toggle source
def replay
print_statement
print_steps
end
result(result)
click to toggle source
def result(result)
@io.write(up(1))
print_step(result.status, @match.arguments, @match.location, true)
end
scenario(scenario)
click to toggle source
def scenario(scenario)
replay
@statement = scenario
end
scenario_outline(scenario_outline)
click to toggle source
def scenario_outline(scenario_outline)
replay
@statement = scenario_outline
end
step(step)
click to toggle source
def step(step)
@steps << step
end
table(rows)
click to toggle source
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.value}"
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
uri(uri)
click to toggle source
def uri(uri)
@uri = uri
end