Class: Cucumber::Formatter::Timed

Inherits:
Progress
  • Object
show all
Defined in:
lib/timed.rb,
lib/cucumber-timed_formatter/version.rb

Constant Summary collapse

VERSION =
'0.1.1'

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ Timed

Returns a new instance of Timed.



6
7
8
9
10
# File 'lib/timed.rb', line 6

def initialize(step_mother, io, options)
  @io = io
  @duration = 0.0
  super
end

Instance Method Details

#after_feature_element(scenario) ⇒ Object



39
40
41
42
# File 'lib/timed.rb', line 39

def after_feature_element(scenario)
  @io.puts " #{scenario.name} (#{@duration}s)"
  @duration = 0.0
end

#after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, *args) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/timed.rb', line 24

def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, *args)
  super
  if status == :failed
    error_msg = "#{exception.message} (#{exception.class.name})\n#{exception.backtrace.join("\n")}"

    @io.puts <<-EOMESSAGE

#{format_string(step_match.backtrace_line, :comment)}

#{format_string(error_msg, status)}

    EOMESSAGE
  end
end

#after_steps(steps) ⇒ Object



20
21
22
# File 'lib/timed.rb', line 20

def after_steps(steps)
  @duration += Time.now - @my_time
end

#before_feature(feature) ⇒ Object



12
13
14
# File 'lib/timed.rb', line 12

def before_feature(feature)
  @io.puts "#{feature.name.lines.first.chomp} [#{feature.file}]"
end

#before_steps(steps) ⇒ Object



16
17
18
# File 'lib/timed.rb', line 16

def before_steps(steps)
  @my_time = Time.now
end