Class: Cucumber::Distrib::Worker::EventBus

Inherits:
Core::EventBus
  • Object
show all
Defined in:
lib/cucumber/distrib/worker/event_bus.rb

Overview

Custom EventBus to collect specific events for Leader.

See Also:

Constant Summary collapse

EVENTS_FOR_LEADER =

List of events to collect for Leader.

[
  ::Cucumber::Events::Envelope,
  ::Cucumber::Events::GherkinSourceParsed,
  ::Cucumber::Events::GherkinSourceRead,
  ::Cucumber::Events::HookTestStepCreated,
  ::Cucumber::Events::StepActivated,
  ::Cucumber::Events::StepDefinitionRegistered,
  ::Cucumber::Events::TestCaseCreated,
  ::Cucumber::Events::TestCaseFinished,
  ::Cucumber::Events::TestCaseReady,
  ::Cucumber::Events::TestCaseStarted,
  # Those are emitted on the leader side:
  # ::Cucumber::Events::TestRunFinished,
  # ::Cucumber::Events::TestRunStarted,
  ::Cucumber::Events::TestStepCreated,
  ::Cucumber::Events::TestStepFinished,
  ::Cucumber::Events::TestStepStarted,
  ::Cucumber::Events::UndefinedParameterType
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventBus

Initialized with Events.worker_registry.



31
32
33
34
# File 'lib/cucumber/distrib/worker/event_bus.rb', line 31

def initialize
  @events_for_leader = []
  super(Cucumber::Distrib::Events.worker_registry)
end

Instance Attribute Details

#events_for_leaderObject (readonly)

Returns the value of attribute events_for_leader.



28
29
30
# File 'lib/cucumber/distrib/worker/event_bus.rb', line 28

def events_for_leader
  @events_for_leader
end

Instance Method Details

#broadcast(event) ⇒ Object

Broadcast an event, but collects it for Leader.



38
39
40
41
42
43
# File 'lib/cucumber/distrib/worker/event_bus.rb', line 38

def broadcast(event)
  super.tap do
    # Collect specific events to send them to Leader after file finishes.
    @events_for_leader << event if EVENTS_FOR_LEADER.any? { |c| event.is_a? c }
  end
end