Class: RubyEventStore::RSpec::HaveApplied

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/rspec/have_applied.rb

Instance Method Summary collapse

Constructor Details

#initialize(*expected, phraser:, failure_message_formatter:) ⇒ HaveApplied

Returns a new instance of HaveApplied.


6
7
8
9
10
11
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 6

def initialize(*expected, phraser:, failure_message_formatter:)
  @expected = ExpectedCollection.new(expected)
  @failure_message_formatter = failure_message_formatter
  @phraser = phraser
  @fetch_events = FetchUnpublishedEvents.new
end

Instance Method Details

#descriptionObject


47
48
49
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 47

def description
  "have applied events that have to (#{phraser.(expected.events)})"
end

#exactly(count) ⇒ Object


19
20
21
22
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 19

def exactly(count)
  expected.exactly(count)
  self
end

#failure_messageObject


39
40
41
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 39

def failure_message
  failure_message_formatter.failure_message(expected, events)
end

#failure_message_when_negatedObject


43
44
45
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 43

def failure_message_when_negated
  failure_message_formatter.failure_message_when_negated(expected, events)
end

#matches?(aggregate_root) ⇒ Boolean

Returns:

  • (Boolean)

13
14
15
16
17
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 13

def matches?(aggregate_root)
  fetch_events.in(aggregate_root)
  @events = fetch_events.call
  MatchEvents.new.call(expected, events)
end

#onceObject


29
30
31
32
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 29

def once
  expected.once
  self
end

#strictObject


34
35
36
37
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 34

def strict
  expected.strict
  self
end

#timesObject Also known as: time


24
25
26
# File 'lib/ruby_event_store/rspec/have_applied.rb', line 24

def times
  self
end