class Cucumber::Formatter::Fuubar

Constants

COLORS

Attributes

runtime[R]
step_mother[R]

Public Class Methods

new(runtime, path_or_io, options) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 15
def initialize(runtime, path_or_io, options)
  @runtime, @io, @options = runtime, ensure_io(path_or_io, "fuubar"), options
  @step_count = @issues_count = 0
end

Public Instance Methods

after_background(background) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 36
def after_background(background)
  @in_background = false
end
after_examples(examples) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 50
def after_examples(examples)
  @is_example = false
end
after_features(features) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 20
def after_features(features)
  @state = :red if runtime.scenarios(:failed).any?
  @io.puts
  @io.puts
  print_summary(features)
end
after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 40
def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
  return if @in_background || status == :skipped
  @state = :red if status == :failed
  progress(status)
end
after_table_row(table_row) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 60
def after_table_row(table_row)
  if @is_example && table_row.is_a?(Cucumber::Ast::OutlineTable::ExampleRow) && table_row.scenario_outline
    progress(:passed, table_row.scenario_outline.instance_variable_get("@steps").count)
  end
end
before_background(background) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 32
def before_background(background)
  @in_background = true
end
before_examples(examples) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 46
def before_examples(examples)
  @is_example = true
end
before_features(features) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 27
def before_features(features)
  @step_count = features.step_count
  @progress_bar = ProgressBar.create(:format => ' %c/%C |%w>%i| %e ', :total => @step_count, :output => @io)
end
before_table_row(table_row) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 54
def before_table_row(table_row)
  if @is_example && table_row.is_a?(Cucumber::Ast::OutlineTable::ExampleRow) && table_row.scenario_outline && table_row.scenario_outline.instance_variable_get("@background").instance_variable_get("@steps")
    progress(:passed, table_row.scenario_outline.instance_variable_get("@background").instance_variable_get("@steps").count)
  end
end
exception(exception, status) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 66
def exception(exception, status)
  @io.print "\e[K" if colors_enabled?
  @issues_count += 1
  @io.puts
  @io.puts "#{@issues_count})"
  print_exception(exception, status, 2)
  @io.puts
  @io.flush
end
on_test_step_finished(event) click to toggle source
# File lib/cucumber/formatter/fuubar3.rb, line 17
def on_test_step_finished(event)
  test_step = event.test_step
  result = event.result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
  progress(result.to_sym) unless hook?(test_step)

  return if hook?(test_step)
  collect_snippet_data(test_step, result)
  @pending_step_matches << @matches[test_step.source] if result.pending?
  @failed_results << result if result.failed?
end
test_run_started(event) click to toggle source
# File lib/cucumber/formatter/fuubar3.rb, line 12
def test_run_started(event)
  steps = event.test_cases.map(&:test_steps).flatten.reject(&method(:hook?))
  @progress_bar = ProgressBar.create(:format => ' %c/%C |%w>%i| %e ', :total => steps.count, :output => @io)
end

Protected Instance Methods

colors_enabled?() click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 101
def colors_enabled?
  Cucumber::Term::ANSIColor.coloring?
end
print_summary(features) click to toggle source
progress(status = 'passed', count = 1) click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 89
def progress(status = 'passed', count = 1)
  with_colors(COLORS[state]) do
    @progress_bar.progress += count
  end
end
state() click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 77
def state
  @state ||= :green
end
with_colors(color) { || ... } click to toggle source
# File lib/cucumber/formatter/fuubar.rb, line 95
def with_colors(color, &block)
  @io.print color if colors_enabled?
  yield
  @io.print "\e[0m" if colors_enabled?
end

Private Instance Methods

hook?(step) click to toggle source
# File lib/cucumber/formatter/fuubar3.rb, line 51
def hook?(step)
  HookQueryVisitor.new(step).hook?
end