class RubyEventStore::RSpec::HaveSubscribedToEvents
Attributes
differ[R]
event_store[R]
expected[R]
handler[R]
matcher[R]
phraser[R]
subscribed_to[R]
Public Class Methods
new(mandatory_expected, *optional_expected, differ:, phraser:)
click to toggle source
# File lib/ruby_event_store/rspec/have_subscribed_to_events.rb, line 6 def initialize(mandatory_expected, *optional_expected, differ:, phraser:) @expected = [mandatory_expected, *optional_expected] @matcher = ::RSpec::Matchers::BuiltIn::ContainExactly.new(expected) @differ = differ @phraser = phraser end
Public Instance Methods
description()
click to toggle source
# File lib/ruby_event_store/rspec/have_subscribed_to_events.rb, line 37 def description "have subscribed to events that have to (#{phraser.(expected)})" end
failure_message()
click to toggle source
# File lib/ruby_event_store/rspec/have_subscribed_to_events.rb, line 27 def failure_message "expected #{handler} to be subscribed to events, diff:" + differ.diff(expected.to_s + "\n", subscribed_to) end
failure_message_when_negated()
click to toggle source
# File lib/ruby_event_store/rspec/have_subscribed_to_events.rb, line 32 def failure_message_when_negated "expected #{handler} not to be subscribed to events, diff:" + differ.diff(expected.to_s + "\n", subscribed_to) end
in(event_store)
click to toggle source
# File lib/ruby_event_store/rspec/have_subscribed_to_events.rb, line 22 def in(event_store) @event_store = event_store self end
matches?(handler)
click to toggle source
# File lib/ruby_event_store/rspec/have_subscribed_to_events.rb, line 13 def matches?(handler) @handler = handler @subscribed_to = expected.select do |event| event_store.subscribers_for(event).include?(handler) end matcher.matches?(subscribed_to) end