class Cucumber::Formatter::Steps
The formatter used for --format steps
Public Class Methods
Source
# File lib/cucumber/formatter/steps.rb, line 10 def initialize(runtime, path_or_io, options) @io = ensure_io(path_or_io, nil) @options = options @step_definition_files = collect_steps(runtime) end
Public Instance Methods
Source
# File lib/cucumber/formatter/steps.rb, line 16 def after_features(_features) print_summary end
Private Instance Methods
Source
# File lib/cucumber/formatter/steps.rb, line 40 def collect_steps(runtime) runtime.step_definitions.each_with_object({}) do |step_definition, step_definitions| step_definitions[step_definition.file] ||= [] step_definitions[step_definition.file] << [step_definition.file_colon_line, step_definition.regexp_source] end end
Source
# File lib/cucumber/formatter/steps.rb, line 22 def print_summary count = 0 @step_definition_files.keys.sort.each do |step_definition_file| @io.puts step_definition_file sources = @step_definition_files[step_definition_file] source_indent = source_indent(sources) sources.sort.each do |file_colon_line, regexp_source| @io.print indent(regexp_source, 2) @io.print indent(" # #{file_colon_line}", source_indent - regexp_source.unpack('U*').length) @io.puts end @io.puts count += sources.size end @io.puts "#{count} step definition(s) in #{@step_definition_files.size} source file(s)." end
Source
# File lib/cucumber/formatter/steps.rb, line 47 def source_indent(sources) sources.map { |_file_colon_line, regexp| regexp.size }.max + 1 end