Class: RubyEventStore::RSpec::HaveSubscribedToEvents
- Inherits:
-
Object
- Object
- RubyEventStore::RSpec::HaveSubscribedToEvents
- Defined in:
- lib/ruby_event_store/rspec/have_subscribed_to_events.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #in(event_store) ⇒ Object
-
#initialize(mandatory_expected, *optional_expected, differ:, phraser:) ⇒ HaveSubscribedToEvents
constructor
A new instance of HaveSubscribedToEvents.
- #matches?(handler) ⇒ Boolean
Constructor Details
#initialize(mandatory_expected, *optional_expected, differ:, phraser:) ⇒ HaveSubscribedToEvents
Returns a new instance of HaveSubscribedToEvents.
6 7 8 9 10 11 |
# 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 |
Instance Method Details
#description ⇒ Object
33 34 35 |
# File 'lib/ruby_event_store/rspec/have_subscribed_to_events.rb', line 33 def description "have subscribed to events that have to (#{phraser.(expected)})" end |
#failure_message ⇒ Object
25 26 27 |
# File 'lib/ruby_event_store/rspec/have_subscribed_to_events.rb', line 25 def "expected #{handler} to be subscribed to events, diff:" + differ.diff(expected.to_s + "\n", subscribed_to) end |
#failure_message_when_negated ⇒ Object
29 30 31 |
# File 'lib/ruby_event_store/rspec/have_subscribed_to_events.rb', line 29 def "expected #{handler} not to be subscribed to events, diff:" + differ.diff(expected.to_s + "\n", subscribed_to) end |
#in(event_store) ⇒ Object
20 21 22 23 |
# File 'lib/ruby_event_store/rspec/have_subscribed_to_events.rb', line 20 def in(event_store) @event_store = event_store self end |
#matches?(handler) ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/ruby_event_store/rspec/have_subscribed_to_events.rb', line 13 def matches?(handler) @handler = handler @subscribed_to = expected.select { |event| event_store.subscribers_for(event).include?(handler) } matcher.matches?(subscribed_to) end |