Class: RubyEventStore::RSpec::StepByStepFailureMessageFormatter::HavePublished
- Inherits:
-
Object
- Object
- RubyEventStore::RSpec::StepByStepFailureMessageFormatter::HavePublished
- Defined in:
- lib/ruby_event_store/rspec/step_by_step_failure_message_formatter.rb
Instance Method Summary collapse
- #failure_message(expected, events, stream_name = nil) ⇒ Object
- #failure_message_when_negated(expected, events, _stream_name = nil) ⇒ Object
-
#initialize(differ, lingo) ⇒ HavePublished
constructor
A new instance of HavePublished.
Constructor Details
#initialize(differ, lingo) ⇒ HavePublished
Returns a new instance of HavePublished.
14 15 16 17 |
# File 'lib/ruby_event_store/rspec/step_by_step_failure_message_formatter.rb', line 14 def initialize(differ, lingo) @differ = differ @lingo = lingo end |
Instance Method Details
#failure_message(expected, events, stream_name = nil) ⇒ Object
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 (expected, events, stream_name = nil) return (expected, events) if expected.strict? return 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, expected_event, stream_name) if expected.specified_count? if correct_event_count >= 1 reality = (expected_event, events_with_correct_type, correct_event_count) elsif !events_with_correct_type.empty? reality = (expected_event, events_with_correct_type) else reality = end else if correct_event_count >= 1 next else if !events_with_correct_type.empty? reality = (expected_event, events_with_correct_type) else reality = end end end return expectations + reality end end |
#failure_message_when_negated(expected, events, _stream_name = nil) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/ruby_event_store/rspec/step_by_step_failure_message_formatter.rb', line 59 def (expected, events, _stream_name = nil) return if expected.empty? if expected.specified_count? <<~EOS expected #{expected.events.first.description} not to be #{lingo.published} exactly #{expected.count} times #{actual_events_list(events)} EOS else <<~EOS expected #{expected_events_list(expected.events)} not to #{"exactly " if expected.strict?}be #{lingo.published} #{actual_events_list(events)} EOS end end |