Class: ActiveSupport::Testing::EventReporterAssertions::EventCollector::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/active_support/testing/event_reporter_assertions.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(event_data) ⇒ Event

Returns a new instance of Event.



14
15
16
# File 'lib/active_support/testing/event_reporter_assertions.rb', line 14

def initialize(event_data)
  @event_data = event_data
end

Instance Attribute Details

#event_dataObject (readonly)

Returns the value of attribute event_data.



12
13
14
# File 'lib/active_support/testing/event_reporter_assertions.rb', line 12

def event_data
  @event_data
end

Instance Method Details

#inspectObject



18
19
20
# File 'lib/active_support/testing/event_reporter_assertions.rb', line 18

def inspect
  "#{event_data[:name]} (payload: #{event_data[:payload].inspect}, tags: #{event_data[:tags].inspect})"
end

#matches?(name, payload, tags) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
29
30
31
# File 'lib/active_support/testing/event_reporter_assertions.rb', line 22

def matches?(name, payload, tags)
  return false unless name.to_s == event_data[:name]

  if payload && payload.is_a?(Hash)
    return false unless matches_hash?(payload, :payload)
  end

  return false unless matches_hash?(tags, :tags)
  true
end