Class: Cucumber::Formatters::ProgressFormatter

Inherits:
Object
  • Object
show all
Includes:
ANSIColor
Defined in:
lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb

Direct Known Subclasses

ProfileFormatter

Constant Summary

Constants included from ANSIColor

ANSIColor::ALIASES

Constants included from Term::ANSIColor

Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP

Instance Method Summary collapse

Methods included from ANSIColor

#grey

Methods included from Term::ANSIColor

attributes, coloring=, coloring?, #uncolored

Constructor Details

#initialize(io) ⇒ ProgressFormatter

Returns a new instance of ProgressFormatter.



8
9
10
11
12
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 8

def initialize(io)
  @io = (io == STDOUT) ? Kernel : io
  @errors             = []
  @pending_scenarios  = []
end

Instance Method Details

#dumpObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 42

def dump
  @io.puts pending
  @io.puts "\nPending Scenarios:\n\n" if @pending_scenarios.any?
  @pending_scenarios.uniq.each_with_index do |scenario, n|
    @io.puts "#{n+1}) #{scenario.feature.header.split("\n").first.gsub(/^(Feature|Story):/, '')} (#{scenario.name})"
  end

  @io.puts failed
  @io.puts "\nFailed:" if @errors.any?
  @errors.each_with_index do |error,n|
    @io.puts
    @io.puts "#{n+1})"
    @io.puts error.message
    @io.puts error.backtrace.join("\n")
  end
  @io.print reset
end

#scenario_executing(scenario) ⇒ Object



14
15
16
17
18
19
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 14

def scenario_executing(scenario)
  if scenario.pending?
    @pending_scenarios << scenario
    @io.print pending("P")
  end
end

#step_failed(step, regexp, args) ⇒ Object



25
26
27
28
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 25

def step_failed(step, regexp, args)
  @errors << step.error
  @io.print failed('F')
end

#step_passed(step, regexp, args) ⇒ Object



21
22
23
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 21

def step_passed(step, regexp, args)
  @io.print passed('.')
end

#step_pending(step, regexp, args) ⇒ Object



30
31
32
33
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 30

def step_pending(step, regexp, args)
  @pending_scenarios << step.scenario
  @io.print pending('P')
end

#step_skipped(step, regexp, args) ⇒ Object



35
36
37
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 35

def step_skipped(step, regexp, args)
  @io.print skipped('_')
end

#step_traced(step, regexp, args) ⇒ Object



39
40
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/progress_formatter.rb', line 39

def step_traced(step, regexp, args)
end