Sha256: f64939a2c64fac16069b0d80f69db9e11fdf2feb1230141b83267ff2be9c49b4

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

module Lucid
  module Formatter
    module Summary

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

      def step_summary(runtime, &block)
        steps_proc = lambda{|status| runtime.steps(status)}
        dump_count(runtime.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

14 entries across 14 versions & 1 rubygems

Version Path
lucid-0.5.1 lib/lucid/formatter/summary.rb
lucid-0.4.1 lib/lucid/formatter/summary.rb
lucid-0.4.0 lib/lucid/formatter/summary.rb
lucid-0.3.3 lib/lucid/formatter/summary.rb
lucid-0.3.0 lib/lucid/formatter/summary.rb
lucid-0.2.1 lib/lucid/formatter/summary.rb
lucid-0.2.0 lib/lucid/formatter/summary.rb
lucid-0.1.1 lib/lucid/formatter/summary.rb
lucid-0.1.0 lib/lucid/formatter/summary.rb
lucid-0.0.9 lib/lucid/formatter/summary.rb
lucid-0.0.8 lib/lucid/formatter/summary.rb
lucid-0.0.7 lib/lucid/formatter/summary.rb
lucid-0.0.6 lib/lucid/formatter/summary.rb
lucid-0.0.5 lib/lucid/formatter/summary.rb