module UglyFace::Formatter::ViewHelper

Public Instance Methods

failed_scenario?(scenario) click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 46
def failed_scenario?(scenario)
  scenario.status == :failed
end
scenario_average_duration(features) click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 31
def scenario_average_duration(features)
  scenarios = features.collect { |feature| feature.scenarios }
  has_duration = scenarios.flatten.reject { |scenario| scenario.duration.nil? }
  durations = has_duration.collect { |scenario| scenario.duration }
  format_duration get_average_from_float_array durations
end
scenario_count() click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 15
def scenario_count
  @step_mother.scenarios.length
end
scenarios_summary_for(status) click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 38
def scenarios_summary_for(status)
  summary_percent(@step_mother.scenarios(status).length, scenario_count)
end
start_time() click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 7
def start_time
  @tests_started.strftime("%a %B %-d, %Y at %H:%M:%S")
end
step_average_duration(features) click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 23
def step_average_duration(features)
  scenarios = features.collect { |feature| feature.scenarios }
  steps = scenarios.flatten.collect { |scenario| scenario.steps }
  has_duration = steps.flatten.reject { |step| step.duration.nil? }
  durations = has_duration.collect { |step| step.duration }
  format_duration get_average_from_float_array durations
end
step_count() click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 11
def step_count
  @step_mother.steps.length
end
steps_summary_for(status) click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 42
def steps_summary_for(status)
  summary_percent(@step_mother.steps(status).length, step_count)
end
total_duration() click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 19
def total_duration
  @duration
end

Private Instance Methods

get_average_from_float_array(arr) click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 53
def get_average_from_float_array(arr)
  arr.reduce(:+).to_f / arr.size
end
summary_percent(number, total) click to toggle source
# File lib/ugly_face/formatter/view_helper.rb, line 57
def summary_percent(number, total)
  percent = (number.to_f / total) * 100
  "#{number} <span class=\"percentage\">(#{'%.1f' % percent}%)</span>"
end