class Cucumber::Formatter::Oneline
Constants
- STATUS_MESSAGES
- VERSION
Attributes
runtime[R]
step_mother[R]
Public Class Methods
new(runtime, path_or_io, options)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 17 def initialize(runtime, path_or_io, options) @runtime, @io, @options = runtime, ensure_io(path_or_io, 'oneline'), options @step_mother = @runtime @file_names = [] @step_details = [] @file_colon_lines = Hash.new{|h,k| h[k] = []} end
Public Instance Methods
after_feature_element(feature_element)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 49 def after_feature_element(feature_element) # Don't print the sum result of an outline scenario unless @scenario_outline file, line = get_file_and_line(feature_element.file_colon_line) progress(@scenario_status, format_file_line(file, line)) if @scenario_status != :passed && @step_details.size > 0 @io.print("\n") @io.print(format_string( "\n\n Scenario steps:\n", @scenario_status )) @step_details.each do |step| @io.print(format_string( "\n #{step}", @scenario_status )) end @io.print("\n") @io.flush end end @scenario_outline = false end
after_features(features)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 93 def after_features(features) @io.puts @io.puts print_summary(features) end
after_step_result(*step_result)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 25 def after_step_result(*step_result) if step_result.first.respond_to?(:status) step_result = step_result.first keyword, step_match, = step_result.keyword, step_result.step_match status, exception = step_result.status, step_result.exception else keyword, step_match, _, status, exception, _, _ = step_result end if status != :skipped @step_details << "#{keyword} #{step_match.format_args('%s')}" end if ![:passed, :skipped, :undefined].include?(status) @step_details << "" @step_details << "#{exception}" @step_details << "#{step_match.backtrace_line}" end end
after_table_row(table_row)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 77 def after_table_row(table_row) if table_row && table_row.respond_to?(:passed?) begin table_row.passed? file, line = get_file_and_line(table_row.backtrace_line) progress(table_row.status, format_file_line(file, line)) update_scenario_status(table_row.status) rescue Cucumber::Ast::OutlineTable::ExampleRow::InvalidForHeaderRowError # Header row for a scenario outline @scenario_outline = true end end reset_scenario_status end
before_feature_element(feature_element)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 45 def before_feature_element(feature_element) reset_scenario_status end
step_name(keyword, step_match, status, source_indent, background, file_colon_line = nil)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 72 def step_name(keyword, step_match, status, source_indent, background, file_colon_line = nil) update_scenario_status(status) end
Private Instance Methods
format_file_line(file, line)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 106 def format_file_line(file, line) "#{file}:L##{line}" end
get_file_and_line(text)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 101 def get_file_and_line(text) file, line = text.split(':') [file, line.gsub(/[^0-9]/, '')] end
print_summary(features)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 142 def print_summary(features) print_steps(:pending) print_steps(:failed) print_stats(features, @options) print_snippets(@options) print_passing_wip(@options) end
progress(status, message = '')
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 125 def progress(status, message = '') @io.print( format_string( "\n[#{Time.now.rfc822}] #{STATUS_MESSAGES[status]} #{message}", status ) ) @io.flush end
reset_scenario_status()
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 110 def reset_scenario_status @scenario_status = :passed @step_details = [] end
update_scenario_status(status)
click to toggle source
# File lib/cucumber/formatter/oneline.rb, line 115 def update_scenario_status(status) if status == :failed @scenario_status = status return end unless [:failed, :pending, :undefined].include?(@scenario_status) @scenario_status = status end end