Module: ActiveSupport::EventReporter::TestHelper

Defined in:
lib/active_support/event_reporter/test_helper.rb

Overview

:nodoc:

Defined Under Namespace

Classes: EventSubscriber

Instance Method Summary collapse

Instance Method Details

#event_matcher(name:, payload: nil, tags: {}, context: {}, source_location: nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/active_support/event_reporter/test_helper.rb', line 16

def event_matcher(name:, payload: nil, tags: {}, context: {}, source_location: nil)
  ->(event) {
    return false unless event[:name] == name
    return false unless event[:payload] == payload
    return false unless event[:tags] == tags
    return false unless event[:context] == context

    [:filepath, :lineno, :label].each do |key|
      if source_location && source_location[key]
        return false unless event[:source_location][key] == source_location[key]
      end
    end

    true
  }
end