Class: RubyEventStore::RSpec::Apply

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

Instance Method Summary collapse

Constructor Details

#initialize(*expected, failure_message_formatter:) ⇒ Apply

Returns a new instance of Apply.


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

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

Instance Method Details

#descriptionObject


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

def description
  "apply events"
end

#exactly(count) ⇒ Object


22
23
24
25
# File 'lib/ruby_event_store/rspec/apply.rb', line 22

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

#failure_messageObject


45
46
47
# File 'lib/ruby_event_store/rspec/apply.rb', line 45

def failure_message
  failure_message_formatter.failure_message(expected, applied_events)
end

#failure_message_when_negatedObject


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

def failure_message_when_negated
  failure_message_formatter.failure_message_when_negated(expected, applied_events)
end

#in(aggregate) ⇒ Object


12
13
14
15
# File 'lib/ruby_event_store/rspec/apply.rb', line 12

def in(aggregate)
  fetch_events.in(aggregate)
  self
end

#matches?(event_proc) ⇒ Boolean

Returns:

  • (Boolean)

37
38
39
40
41
42
43
# File 'lib/ruby_event_store/rspec/apply.rb', line 37

def matches?(event_proc)
  raise_aggregate_not_set unless fetch_events.aggregate?
  before = fetch_events.aggregate.unpublished_events.to_a
  event_proc.call
  @applied_events = fetch_events.aggregate.unpublished_events.to_a - before
  MatchEvents.new.call(expected, applied_events)
end

#onceObject


32
33
34
35
# File 'lib/ruby_event_store/rspec/apply.rb', line 32

def once
  expected.once
  self
end

#strictObject


17
18
19
20
# File 'lib/ruby_event_store/rspec/apply.rb', line 17

def strict
  expected.strict
  self
end

#supports_block_expectations?Boolean

Returns:

  • (Boolean)

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

def supports_block_expectations?
  true
end

#timesObject Also known as: time


27
28
29
# File 'lib/ruby_event_store/rspec/apply.rb', line 27

def times
  self
end