module PrettyFace::Formatter::ViewHelper
Public Instance Methods
failed_scenario?(scenario)
click to toggle source
# File lib/pretty_face/formatter/view_helper.rb, line 44 def failed_scenario?(scenario) scenario.status == :failed end
scenario_average_duration(features)
click to toggle source
# File lib/pretty_face/formatter/view_helper.rb, line 30 def scenario_average_duration(features) scenarios = features.collect { |feature| feature.scenarios } durations = scenarios.flatten.collect { |scenario| scenario.duration } format_duration get_average_from_float_array durations end
scenario_count()
click to toggle source
# File lib/pretty_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/pretty_face/formatter/view_helper.rb, line 36 def scenarios_summary_for(status) summary_percent(@step_mother.scenarios(status).length, scenario_count) end
start_time()
click to toggle source
# File lib/pretty_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/pretty_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 } durations = steps.flatten.collect { |step| step.duration } format_duration get_average_from_float_array durations end
step_count()
click to toggle source
# File lib/pretty_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/pretty_face/formatter/view_helper.rb, line 40 def steps_summary_for(status) summary_percent(@step_mother.steps(status).length, step_count) end
total_duration()
click to toggle source
# File lib/pretty_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/pretty_face/formatter/view_helper.rb, line 51 def get_average_from_float_array(arr) arr.reduce(:+).to_f / arr.size end
summary_percent(number, total)
click to toggle source
# File lib/pretty_face/formatter/view_helper.rb, line 55 def summary_percent(number, total) percent = (number.to_f / total) * 100 "#{number} <span class=\"percentage\">(#{'%.1f' % percent}%)</span>" end