Sha256: acf49462b7b165ff6c1c5f58dd70c11be3c52c8eea62a2d8af631153c9ee5ee1

Contents?: true

Size: 1.16 KB

Versions: 17

Compression:

Stored size: 1.16 KB

Contents

# -*- coding: utf-8 -*-

require 'turnip_formatter/printer'
require 'ostruct'

module TurnipFormatter
  module Printer
    module TabFeatureStatistics
      class << self
        include TurnipFormatter::Printer

        def print_out(scenarios)
          features = scenarios.group_by { |s| s.feature_name }

          results = features.map do |name, feature_scenarios|
            feature_analysis(name, feature_scenarios)
          end

          render_template(:tab_feature_statistics, { analysis_results: results })
        end

        private

        def feature_analysis(name, scenarios)
          status_group = scenarios.group_by { |s| s.status }
          status_group.default = []

          info = OpenStruct.new(
            name: name,
            scenario_count: scenarios.size,
            passed_count: status_group["passed"].size,
            failed_count: status_group["failed"].size,
            pending_count: status_group["pending"].size,
            status: 'failed'
          )

          if info.failed_count.zero?
            info.status = info.pending_count.zero? ? 'passed' : 'pending'
          end

          info
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
turnip_formatter-0.6.0.pre.beta.2 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.6.0.pre.beta.1 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.5.0 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.4.0 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.3.4 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.3.3 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.3.2 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.3.1 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.3.0 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.11 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.10 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.9 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.8 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.7 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.6 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.5 lib/turnip_formatter/printer/tab_feature_statistics.rb
turnip_formatter-0.2.4 lib/turnip_formatter/printer/tab_feature_statistics.rb