Class: Cucumber::Formatters::ProfileFormatter
- Inherits:
-
ProgressFormatter
- Object
- ProgressFormatter
- Cucumber::Formatters::ProfileFormatter
- Defined in:
- lib/gems/cucumber-0.1.15/lib/cucumber/formatters/profile_formatter.rb
Constant Summary collapse
- NUMBER_OF_STEP_DEFINITONS_TO_SHOW =
10
- NUMBER_OF_STEP_INVOCATIONS_TO_SHOW =
5
Constants included from ANSIColor
Constants included from Term::ANSIColor
Term::ANSIColor::ATTRIBUTES, Term::ANSIColor::ATTRIBUTE_NAMES, Term::ANSIColor::COLORED_REGEXP
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(io, step_mother) ⇒ ProfileFormatter
constructor
A new instance of ProfileFormatter.
- #step_executing(step, regexp, args) ⇒ Object
- #step_passed(step, regexp, args) ⇒ Object
- #visit_features(features) ⇒ Object
Methods inherited from ProgressFormatter
#scenario_executing, #step_failed, #step_pending, #step_skipped, #step_traced
Methods included from ANSIColor
Methods included from Term::ANSIColor
attributes, coloring=, coloring?, #uncolored
Constructor Details
#initialize(io, step_mother) ⇒ ProfileFormatter
Returns a new instance of ProfileFormatter.
7 8 9 10 11 12 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/profile_formatter.rb', line 7 def initialize(io, step_mother) super(io) @step_mother = step_mother @step_times = Hash.new { |k,v| k[v] = [] } @step_keywords = {} end |
Instance Method Details
#dump ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/profile_formatter.rb', line 42 def dump super @io.puts "\n\nTop #{NUMBER_OF_STEP_DEFINITONS_TO_SHOW} average slowest steps with #{NUMBER_OF_STEP_INVOCATIONS_TO_SHOW} slowest matches:\n" mean_times = map_to_mean_times(@step_times) mean_times = mean_times.sort_by { |step_profiles, keyword_regexp, mean_execution_time| mean_execution_time }.reverse mean_times[0...NUMBER_OF_STEP_DEFINITONS_TO_SHOW].each do |step_profiles, keyword_regexp, mean_execution_time| print_step_definition(step_profiles, keyword_regexp, mean_execution_time) step_profiles = step_profiles.sort_by { |description, invocation_comment, definition_comment, execution_time| execution_time }.reverse print_step_invocations(step_profiles, keyword_regexp) end end |
#step_executing(step, regexp, args) ⇒ Object
18 19 20 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/profile_formatter.rb', line 18 def step_executing(step, regexp, args) @step_time = Time.now end |
#step_passed(step, regexp, args) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/gems/cucumber-0.1.15/lib/cucumber/formatters/profile_formatter.rb', line 22 def step_passed(step, regexp, args) execution_time = Time.now - @step_time super @step_keywords[regexp] ||= step.actual_keyword unless step.row? invocation_comment = '' definition_comment = '' if step.row? description = '' args.each do |arg| description += %{|#{arg}|} end else description = "#{step.keyword} #{step.format(regexp){|param| underline(param)}}" definition_comment = source(step) end invocation_comment = "# #{step.file}:#{step.line}" @step_times["#{@step_keywords[regexp]} #{regexp.inspect}"] << [description, invocation_comment, definition_comment, execution_time] end |