Class: CucumberStatistics::ScenarioStatistics

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber_statistics/scenario_statistics.rb

Instance Method Summary collapse

Constructor Details

#initializeScenarioStatistics

Returns a new instance of ScenarioStatistics.



3
4
5
# File 'lib/cucumber_statistics/scenario_statistics.rb', line 3

def initialize
  @all = Hash.new
end

Instance Method Details

#allObject



18
19
20
# File 'lib/cucumber_statistics/scenario_statistics.rb', line 18

def all
  @all
end

#record(scenario_name, duration, file_colon_line) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/cucumber_statistics/scenario_statistics.rb', line 7

def record scenario_name, duration, file_colon_line
  short_file_colon_line = file_colon_line[file_colon_line.index('features').to_i..-1]

  scenario_result = @all[short_file_colon_line]
  scenario_result ||= Hash.new
  scenario_result[:duration] = duration
  scenario_result[:scenario_name] = scenario_name

  @all[short_file_colon_line] ||= scenario_result
end

#sort_by_property(property) ⇒ Object



22
23
24
25
# File 'lib/cucumber_statistics/scenario_statistics.rb', line 22

def sort_by_property property
  result = @all.sort {|a,b| a.last[property.to_sym] <=> b.last[property.to_sym]}
  result
end