Sha256: bdee6e4a2935b399d701f43d601641d6c4ad0f1dbd7101980379991a0205c325
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
# -*- coding: utf-8 -*- require 'turnip_formatter/printer' require 'ostruct' module TurnipFormatter module Printer class TabTagStatistics class << self include TurnipFormatter::Printer def print_out(scenarios) tags = group_by_tag(scenarios) results = tags.map do |name, tag_scenarios| tag_analysis(name, tag_scenarios) end render_template(:tab_tag_statistics, { analysis_results: results }) end private def tag_analysis(name, scenarios) status_group = scenarios.group_by { |s| s[:scenario].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 # # Image... # # [ # { tags: [:a, :b], val: 3 }, # { tags: [:a], val: 4 }, # { tags: [:b], val: 5 }, # ] # # => [ # [:a, [3, 4]], # [:b, [3, 5]], # ] # # def group_by_tag(scenarios) scenarios.map do |scenario| if scenario.tags.empty? { name: 'turnip', scenario: scenario } else scenario.tags.map do |tag| { name: '@' + tag, scenario: scenario } end end end.flatten.group_by { |s| s[:name] }.sort end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
turnip_formatter-0.2.4 | lib/turnip_formatter/printer/tab_tag_statistics.rb |