Sha256: d9b2987e9b1af0110cb1ee6a710490c2e0c2d977f257d1171ff1511432ada23e

Contents?: true

Size: 1.04 KB

Versions: 103

Compression:

Stored size: 1.04 KB

Contents

module Cucumber
  module Formatter
    module Summary

      def scenario_summary(step_mother, &block)
        scenarios_proc = lambda{|status| step_mother.scenarios(status)}
        dump_count(step_mother.scenarios.length, "scenario") + dump_status_counts(scenarios_proc, &block)
      end

      def step_summary(step_mother, &block)
        steps_proc = lambda{|status| step_mother.steps(status)}
        dump_count(step_mother.steps.length, "step") + dump_status_counts(steps_proc, &block)
      end

      private

      def dump_status_counts(find_elements_proc)
        counts = [:failed, :skipped, :undefined, :pending, :passed].map do |status|
          elements = find_elements_proc.call(status)
          elements.any? ? yield("#{elements.length} #{status.to_s}", status) : nil
        end.compact
        if counts.any?
          " (#{counts.join(', ')})"
        else
          ""
        end
      end

      def dump_count(count, what, state=nil)
        [count, state, "#{what}#{count == 1 ? '' : 's'}"].compact.join(" ")
      end

    end
  end
end

Version data entries

103 entries across 101 versions & 16 rubygems

Version Path
middleman-0.10.14 vendor/gems/gems/cucumber-0.4.4/lib/cucumber/formatter/summary.rb
cucumber-0.4.4 lib/cucumber/formatter/summary.rb
cucumber-0.4.3 lib/cucumber/formatter/summary.rb