class StepStats::Step
Attributes
definition[RW]
location[RW]
name[RW]
Public Class Methods
new(step_def_name, step_def_location)
click to toggle source
# File lib/step_stats/step.rb, line 5 def initialize(step_def_name, step_def_location) @name = step_def_name @location = step_def_location # An Array of hashs with duration, status and location # step_info = {duration: 5.21692, status: :pass, location: 'feature/...feature:219'} @step_entries = [] end
Public Instance Methods
add(step_entry)
click to toggle source
# File lib/step_stats/step.rb, line 17 def add step_entry @step_entries << step_entry end
avg()
click to toggle source
# File lib/step_stats/step.rb, line 29 def avg (total / count.to_f).round(3) end
count()
click to toggle source
# File lib/step_stats/step.rb, line 37 def count durations.count end
durations()
click to toggle source
# File lib/step_stats/step.rb, line 13 def durations @durations || @step_entries.map{|step| step[:duration]} end
max()
click to toggle source
# File lib/step_stats/step.rb, line 25 def max durations.max.to_f.round(3) end
min()
click to toggle source
# File lib/step_stats/step.rb, line 21 def min durations.min.to_f.round(3) end
stddev()
click to toggle source
# File lib/step_stats/step.rb, line 41 def stddev return 0.to_f if count == 1 total = durations.inject(0){|accum, i| accum +(i-avg)**2 } variance = total/(count - 1).to_f Math.sqrt(variance).round(3) end
to_chart_data()
click to toggle source
# File lib/step_stats/step.rb, line 48 def to_chart_data @step_entries.map(&:values).each_with_index.map do |s, index| step_entry = [(index + 1).to_s,s[0]] if s[1] == :passed step_entry << "green" else step_entry << "red" end step_entry << "Location: #{s[2]} \n Time: #{s[0]} seconds" step_entry end.to_s end
total()
click to toggle source
# File lib/step_stats/step.rb, line 33 def total durations.sum end