Class: Cucumber::Formatters::ProgressFormatter

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

Direct Known Subclasses

ProfileFormatter

Constant Summary

Constants included from ANSIColor

ANSIColor::ALIASES

Instance Method Summary collapse

Methods included from ANSIColor

#grey

Constructor Details

#initialize(io) ⇒ ProgressFormatter

Returns a new instance of ProgressFormatter.



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

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

Instance Method Details

#dumpObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/cucumber/formatters/progress_formatter.rb', line 32

def dump
  @io.puts pending
  @io.puts "\nPending Scenarios:\n\n" if @pending.any?
  @pending.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

#step_failed(step, regexp, args) ⇒ Object



18
19
20
21
# File 'lib/cucumber/formatters/progress_formatter.rb', line 18

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

#step_passed(step, regexp, args) ⇒ Object



14
15
16
# File 'lib/cucumber/formatters/progress_formatter.rb', line 14

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

#step_pending(step, regexp, args) ⇒ Object



23
24
25
26
# File 'lib/cucumber/formatters/progress_formatter.rb', line 23

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

#step_skipped(step, regexp, args) ⇒ Object



28
29
30
# File 'lib/cucumber/formatters/progress_formatter.rb', line 28

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