Sha256: 4489cae94d70828ef86e3989d38b9f673007a39ad24292ab98529a4a94b49ba6

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

module Specjour::Cucumber
  class DistributedFormatter < ::Cucumber::Formatter::Progress
    class << self
      attr_accessor :batch_size
    end
    @batch_size = 1

    def initialize(step_mother, io, options)
      @step_mother = step_mother
      @io = io
      @options = options
      @failing_scenarios = []
    end

    def after_features(features)
      print_summary
      step_mother.scenarios.clear
      step_mother.steps.clear
    end

    def prepare_failures
      @failures = step_mother.scenarios(:failed).select { |s| s.is_a?(Cucumber::Ast::Scenario) }

      if !@failures.empty?
        @failures.each do |failure|
          failure_message = ''
          failure_message += format_string("cucumber " + failure.file_colon_line, :failed) +
          failure_message += format_string(" # Scenario: " + failure.name, :comment)
          @failing_scenarios << failure_message
        end
      end
    end

    def print_summary
      prepare_failures

      @io.send_message(:worker_summary=, to_hash)
    end

    OUTCOMES = [:failed, :skipped, :undefined, :pending, :passed]

    def to_hash
      hash = {}
      [:scenarios, :steps].each do |type|
        hash[type] = {}
        OUTCOMES.each do |outcome|
          hash[type][outcome] = step_mother.send(type, outcome).size
        end
      end
      hash.merge!(:failing_scenarios => @failing_scenarios)
      hash
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
specjour-0.2.1 lib/specjour/cucumber/distributed_formatter.rb
specjour-0.2.0 lib/specjour/cucumber/distributed_formatter.rb