Class: VcrStripeWebhook::EventTypeWaiter
- Inherits:
-
Object
- Object
- VcrStripeWebhook::EventTypeWaiter
- Defined in:
- lib/vcr_stripe_webhook/waiter.rb
Instance Attribute Summary collapse
-
#event_types ⇒ Object
readonly
Returns the value of attribute event_types.
Instance Method Summary collapse
- #call(events) ⇒ Object
-
#initialize(event_types) ⇒ EventTypeWaiter
constructor
A new instance of EventTypeWaiter.
- #timeout_message(events, recording:) ⇒ Object
Constructor Details
#initialize(event_types) ⇒ EventTypeWaiter
Returns a new instance of EventTypeWaiter.
22 23 24 |
# File 'lib/vcr_stripe_webhook/waiter.rb', line 22 def initialize(event_types) @event_types = event_types end |
Instance Attribute Details
#event_types ⇒ Object (readonly)
Returns the value of attribute event_types.
20 21 22 |
# File 'lib/vcr_stripe_webhook/waiter.rb', line 20 def event_types @event_types end |
Instance Method Details
#call(events) ⇒ Object
26 27 28 29 |
# File 'lib/vcr_stripe_webhook/waiter.rb', line 26 def call(events) type_set = events.map(&:type).to_set event_types.all? { |type| type_set.member?(type) } end |
#timeout_message(events, recording:) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/vcr_stripe_webhook/waiter.rb', line 31 def (events, recording:) type_set = events.map(&:type).to_set missing_event_types = event_types.reject { |type| type_set.member?(type) } events_words = recording ? "Received events" : "The recorded events" types_words = missing_event_types.map { |type| "'#{type}'" }.join(", ") "#{events_words} don't contain #{types_words}." end |