class RubyEventStore::RSpec::MatchEvents

Public Instance Methods

call(expected, events) click to toggle source
# File lib/ruby_event_store/rspec/match_events.rb, line 4
def call(expected, events)
  if match_events?(expected)
    matcher(expected).matches?(events) && matches_count?(expected, events)
  else
    !events.empty?
  end
end

Private Instance Methods

match_events?(expected) click to toggle source
# File lib/ruby_event_store/rspec/match_events.rb, line 27
def match_events?(expected)
  !expected.empty?
end
matcher(expected) click to toggle source
# File lib/ruby_event_store/rspec/match_events.rb, line 19
def matcher(expected)
  if expected.strict?
    ::RSpec::Matchers::BuiltIn::Match.new(expected.events)
  else
    ::RSpec::Matchers::BuiltIn::Include.new(*expected.events)
  end
end
matches_count?(expected, events) click to toggle source
# File lib/ruby_event_store/rspec/match_events.rb, line 14
def matches_count?(expected, events)
  return true unless expected.specified_count?
  events.select { |e| expected.event === e }.size.equal?(expected.count)
end