class RubyEventStore::RSpec::Publish

Attributes

expected[R]
failed_on_stream[R]
failure_message_formatter[R]
fetch_events[R]
published_events[R]

Public Class Methods

new(*expected, failure_message_formatter:) click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 6
def initialize(*expected, failure_message_formatter:)
  @expected = ExpectedCollection.new(expected)
  @failure_message_formatter = failure_message_formatter
  @fetch_events = FetchEvents.new
end

Public Instance Methods

description() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 68
def description
  "publish events"
end
exactly(count) click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 27
def exactly(count)
  expected.exactly(count)
  self
end
failure_message() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 60
def failure_message
  failure_message_formatter.failure_message(expected, published_events, failed_on_stream)
end
failure_message_when_negated() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 64
def failure_message_when_negated
  failure_message_formatter.failure_message_when_negated(expected, published_events, fetch_events.stream_name)
end
in(event_store) click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 12
def in(event_store)
  fetch_events.in(event_store)
  self
end
in_stream(stream_name) click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 17
def in_stream(stream_name)
  @stream_names = [stream_name]
  self
end
in_streams(stream_names) click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 22
def in_streams(stream_names)
  @stream_names = Array(stream_names)
  self
end
matches?(event_proc) click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 47
def matches?(event_proc)
  fetch_events.from_last
  event_proc.call
  stream_names.all? do |stream_name|
    fetch_events.stream(stream_name)
    @published_events = fetch_events.call.to_a
    @failed_on_stream = stream_name
    MatchEvents.new.call(expected, published_events)
  end
rescue FetchEvents::MissingEventStore
  raise "You have to set the event store instance with `in`, e.g. `expect { ... }.to publish(an_event(MyEvent)).in(event_store)`"
end
once() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 32
def once
  expected.once
  self
end
strict() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 42
def strict
  expected.strict
  self
end
supports_block_expectations?() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 72
def supports_block_expectations?
  true
end
time()
Alias for: times
times() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 37
def times
  self
end
Also aliased as: time

Private Instance Methods

stream_names() click to toggle source
# File lib/ruby_event_store/rspec/publish.rb, line 78
def stream_names
  @stream_names || [nil]
end