class Turnip::DryRun::TextFormatter

Public Instance Methods

example_passed(notification) click to toggle source
# File lib/turnip/dry_run/text_formatter.rb, line 9
def example_passed(notification)
  # FIXME
  example = notification.respond_to?(:example) ? notification.example : notification

  feature_path_width = example.metadata[:steps].map {|s|
    "#{s.feature_file}:#{s.step.line}".size
  }.max
  step_width = example.metadata[:steps].map {|s|
    s.step.description.size
  }.max
  method_name_width = example.metadata[:steps].map {|s|
    s.method_name.size
  }.max
  method_path_width = example.metadata[:steps].map {|s|
    "#{s.method_filename}:#{s.method_lineno}".size
  }.max
  example.metadata[:steps].each do |s|
    m = ["#{s.feature_file}:#{s.step.line}", s.step.description, "#{s.method_filename}:#{s.method_lineno}", s.method_name]
    output << "%-#{feature_path_width}s %-#{step_width}s -> %-#{method_path_width}s %-#{method_name_width}s#{$/}" % m
  end
end