Class: CucumberTimingPresenter::TimingFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_timing_presenter/timing_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ TimingFormatter

Returns a new instance of TimingFormatter.



3
4
5
6
7
8
9
10
# File 'lib/cucumber_timing_presenter/timing_formatter.rb', line 3

def initialize(step_mother, io, options)
  @step_mother = step_mother
  @io = io
  @options = options
  
  @usage_record = UsageRecord.new
  @unused_steps = UnusedSteps.new
end

Instance Method Details

#after_features(features) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/cucumber_timing_presenter/timing_formatter.rb', line 25

def after_features(features)
  get_unused_stepdefs
  
  @usage_record.calculate

  AllUsageResultsHtmlPresenter.new @usage_record
  UnusedStepsHtmlPresenter.new @unused_steps
  StepAverageAndTotalHtmlPresenter.new @usage_record
  StepTimesOfWholeHtmlPresenter.new @usage_record
end

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



21
22
23
# File 'lib/cucumber_timing_presenter/timing_formatter.rb', line 21

def after_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
  @usage_record.record step_match.step_definition.regexp_source, @duration
end

#before_step(step) ⇒ Object

call backs



13
14
15
# File 'lib/cucumber_timing_presenter/timing_formatter.rb', line 13

def before_step(step)
  @start_time = Time.now
end

#before_step_result(*args) ⇒ Object



17
18
19
# File 'lib/cucumber_timing_presenter/timing_formatter.rb', line 17

def before_step_result(*args)
  @duration = Time.now - @start_time
end

#get_unused_stepdefsObject

helpers



38
39
40
41
42
# File 'lib/cucumber_timing_presenter/timing_formatter.rb', line 38

def get_unused_stepdefs
  @step_mother.unmatched_step_definitions.each do |step_definition|
    @unused_steps.record step_definition.regexp_source, step_definition.file_colon_line
  end
end