Sha256: b0226b8b83cb23e808ac2714e63a6fcb2facd1e795e106964b303ad96257f124

Contents?: true

Size: 1.58 KB

Versions: 13

Compression:

Stored size: 1.58 KB

Contents

require 'cucumber/ast/scenario_outline'

module PrettyFace
  module Formatter
    module ViewHelper

      def start_time
        @tests_started.strftime("%a %B %-d, %Y at %H:%M:%S")
      end

      def step_count
        @step_mother.steps.length
      end

      def scenario_count
        @step_mother.scenarios.length
      end

      def total_duration
        @duration
      end

      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

      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

      def scenarios_summary_for(status)
        summary_percent(@step_mother.scenarios(status).length, scenario_count)
      end

      def steps_summary_for(status)
        summary_percent(@step_mother.steps(status).length, step_count)
      end

      def failed_scenario?(scenario)
        scenario.status == :failed
      end


      private

      def get_average_from_float_array(arr)
        arr.reduce(:+).to_f / arr.size
      end

      def summary_percent(number, total)
        percent = (number.to_f / total) * 100
        "#{number} <span class=\"percentage\">(#{'%.1f' % percent}%)</span>"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
pretty_face-0.10.3 lib/pretty_face/formatter/view_helper.rb
sponte_pretty_face-0.10.3 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.10.2 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.10.1 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.10 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.9.1 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.9 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.8.2 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.8.1 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.8 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.7 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.6.1 lib/pretty_face/formatter/view_helper.rb
pretty_face-0.6 lib/pretty_face/formatter/view_helper.rb