19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/ruby_event_store/rspec/step_by_step_failure_message_formatter.rb', line 19
def failure_message(expected, events, stream_name = nil)
return failure_message_strict(expected, events) if expected.strict?
return failure_message_no_events if expected.empty?
expected.events.each do |expected_event|
correct_event_count = 0
events_with_correct_type = []
events.each do |actual_event|
if expected_event.matches?(actual_event)
correct_event_count += 1
elsif expected_event.matches_kind?(actual_event)
events_with_correct_type << actual_event
end
end
expectations = expected_message(expected, expected_event, stream_name)
if expected.specified_count?
if correct_event_count >= 1
reality = failure_message_incorrect_count(expected_event, events_with_correct_type, correct_event_count)
elsif !events_with_correct_type.empty?
reality = failure_message_correct_type_incorrect_payload(expected_event, events_with_correct_type)
else
reality = failure_message_incorrect_type
end
else
if correct_event_count >= 1
next
else
if !events_with_correct_type.empty?
reality = failure_message_correct_type_incorrect_payload(expected_event, events_with_correct_type)
else
reality = failure_message_incorrect_type
end
end
end
return expectations + reality
end
end
|