Class: RubyEventStore::RSpec::HavePublished

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of HavePublished.



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

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

Instance Method Details

#descriptionObject



61
62
63
# File 'lib/ruby_event_store/rspec/have_published.rb', line 61

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

#exactly(count) ⇒ Object



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

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

#failure_messageObject



53
54
55
# File 'lib/ruby_event_store/rspec/have_published.rb', line 53

def failure_message
  failure_message_formatter.failure_message(expected, published_events, failed_on_stream)
end

#failure_message_when_negatedObject



57
58
59
# File 'lib/ruby_event_store/rspec/have_published.rb', line 57

def failure_message_when_negated
  failure_message_formatter.failure_message_when_negated(expected, published_events, failed_on_stream)
end

#from(event_id) ⇒ Object



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

def from(event_id)
  fetch_events.from(event_id)
  self
end

#in_stream(stream_name) ⇒ Object



28
29
30
31
# File 'lib/ruby_event_store/rspec/have_published.rb', line 28

def in_stream(stream_name)
  @stream_names = [stream_name]
  self
end

#in_streams(stream_names) ⇒ Object



33
34
35
36
# File 'lib/ruby_event_store/rspec/have_published.rb', line 33

def in_streams(stream_names)
  @stream_names = Array(stream_names)
  self
end

#matches?(event_store) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
# File 'lib/ruby_event_store/rspec/have_published.rb', line 13

def matches?(event_store)
  stream_names.all? do |stream_name|
    fetch_events.stream(stream_name)
    fetch_events.in(event_store)
    @published_events = fetch_events.call.to_a
    @failed_on_stream = stream_name
    MatchEvents.new.call(expected, published_events)
  end
end

#onceObject



48
49
50
51
# File 'lib/ruby_event_store/rspec/have_published.rb', line 48

def once
  expected.once
  self
end

#strictObject



65
66
67
68
# File 'lib/ruby_event_store/rspec/have_published.rb', line 65

def strict
  expected.strict
  self
end

#timesObject Also known as: time



38
39
40
# File 'lib/ruby_event_store/rspec/have_published.rb', line 38

def times
  self
end