Class: RubyEventStore::RSpec::HavePublished
- Inherits:
-
Object
- Object
- RubyEventStore::RSpec::HavePublished
- Defined in:
- lib/ruby_event_store/rspec/have_published.rb
Instance Method Summary collapse
- #description ⇒ Object
- #exactly(count) ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
- #from(event_id) ⇒ Object
- #in_stream(stream_name) ⇒ Object
- #in_streams(stream_names) ⇒ Object
-
#initialize(*expected, phraser:, failure_message_formatter:) ⇒ HavePublished
constructor
A new instance of HavePublished.
- #matches?(event_store) ⇒ Boolean
- #once ⇒ Object
- #strict ⇒ Object
- #times ⇒ Object (also: #time)
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 = @fetch_events = FetchEvents.new end |
Instance Method Details
#description ⇒ Object
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_message ⇒ Object
53 54 55 |
# File 'lib/ruby_event_store/rspec/have_published.rb', line 53 def .(expected, published_events, failed_on_stream) end |
#failure_message_when_negated ⇒ Object
57 58 59 |
# File 'lib/ruby_event_store/rspec/have_published.rb', line 57 def .(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
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 |
#once ⇒ Object
48 49 50 51 |
# File 'lib/ruby_event_store/rspec/have_published.rb', line 48 def once expected.once self end |
#strict ⇒ Object
65 66 67 68 |
# File 'lib/ruby_event_store/rspec/have_published.rb', line 65 def strict expected.strict self end |
#times ⇒ Object Also known as: time
38 39 40 |
# File 'lib/ruby_event_store/rspec/have_published.rb', line 38 def times self end |