Class: Cucumber::Formatter::Profiler

Inherits:
Object
  • Object
show all
Includes:
Console, Io
Defined in:
lib/cucumber/formatter/profiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, path_or_io, options) ⇒ Profiler

Returns a new instance of Profiler.



37
38
39
40
# File 'lib/cucumber/formatter/profiler.rb', line 37

def initialize(step_mother, path_or_io, options)
  @step_mother, @io, @options, @durations = step_mother, ensure_io(path_or_io, "fuubar"), options, []
  @timed_features = {}
end

Instance Attribute Details

#step_motherObject (readonly)

Returns the value of attribute step_mother.



35
36
37
# File 'lib/cucumber/formatter/profiler.rb', line 35

def step_mother
  @step_mother
end

Instance Method Details

#after_feature_element(feature_element) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cucumber/formatter/profiler.rb', line 56

def after_feature_element(feature_element)
  feature_element.finished_at = Time.now
  feature_element.run_time = feature_element.finished_at - feature_element.started_at
  key = feature_element.feature.title
  if @timed_features.has_key? key
    @timed_features[key] = @timed_features[key] << feature_element
  else
    @timed_features[key] = [feature_element]
  end

  progress(:failed) if @exception_raised
  @exception_raised = false
end

#after_features(features) ⇒ Object



43
44
45
46
47
# File 'lib/cucumber/formatter/profiler.rb', line 43

def after_features(features)
  @io.puts
  @io.puts
  print_summary(features)
end

#after_outline_table(outline_table) ⇒ Object



88
89
90
# File 'lib/cucumber/formatter/profiler.rb', line 88

def after_outline_table(outline_table)
  @outline_table = nil
end

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



79
80
81
82
# File 'lib/cucumber/formatter/profiler.rb', line 79

def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
  progress(status)
  @status = status
end

#after_steps(*args) ⇒ Object



75
76
77
# File 'lib/cucumber/formatter/profiler.rb', line 75

def after_steps(*args)
  @exception_raised = false
end

#before_feature_element(feature_element) ⇒ Object



50
51
52
53
54
# File 'lib/cucumber/formatter/profiler.rb', line 50

def before_feature_element(feature_element)
  feature_element.extend Cucumber::Ast::Benchmark
  feature_element.started_at = Time.now
  @exception_raised = false
end

#before_outline_table(outline_table) ⇒ Object



84
85
86
# File 'lib/cucumber/formatter/profiler.rb', line 84

def before_outline_table(outline_table)
  @outline_table = outline_table
end

#before_steps(*args) ⇒ Object



70
71
72
73
# File 'lib/cucumber/formatter/profiler.rb', line 70

def before_steps(*args)
  progress(:failed) if @exception_raised
  @exception_raised = false
end

#exception(*args) ⇒ Object



98
99
100
# File 'lib/cucumber/formatter/profiler.rb', line 98

def exception(*args)
  @exception_raised = true
end

#table_cell_value(value, status) ⇒ Object



92
93
94
95
96
# File 'lib/cucumber/formatter/profiler.rb', line 92

def table_cell_value(value, status)
  return unless @outline_table
  status ||= @status
  progress(status) unless table_header_cell?(status)
end