Sha256: 9b575ec128bd06d9135e3e4f99bfe62432a8726d25009c2276bd6180236a5543

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true
module Cucumber
  module Core
    module Report
      class Summary
        attr_reader :test_cases, :test_steps

        def initialize(event_bus)
          @test_cases = Test::Result::Summary.new
          @test_steps = Test::Result::Summary.new
          subscribe_to(event_bus)
        end

        private

        def subscribe_to(event_bus)
          event_bus.on(:test_case_finished) do |event|
            event.result.describe_to test_cases
          end
          event_bus.on(:test_step_finished) do |event|
            event.result.describe_to test_steps if is_step?(event.test_step)
          end
          self
        end

        def is_step?(test_step)
          StepQueryVisitor.new(test_step).is_step?
        end
      end

      class StepQueryVisitor
        def initialize(test_step)
          @step = false
          test_step.source.last.describe_to(self)
        end

        def is_step?
          @step
        end

        def step(*)
          @step = true
        end
        
        def method_missing(*)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cucumber-core-2.0.0 lib/cucumber/core/report/summary.rb