Class: RSpec::SSE::Matchers::ContainExactlyMatcher
- Inherits:
-
BaseMatcher
- Object
- BaseMatcher
- RSpec::SSE::Matchers::ContainExactlyMatcher
- Defined in:
- lib/rspec/sse/matchers.rb
Overview
Base matcher for contain exactly matching (order doesn’t matter)
Direct Known Subclasses
ContainExactlyEventData, ContainExactlyEventIds, ContainExactlyEventTypes, ContainExactlyEvents, ContainExactlyReconnectionTimes
Instance Method Summary collapse
- #description ⇒ Object
-
#match_condition ⇒ Object
Match if extracted actual values match expected values in any order.
Methods inherited from BaseMatcher
#failure_message, #failure_message_when_negated, #initialize, #match_arrays, #match_items, #matches?
Constructor Details
This class inherits a constructor from RSpec::SSE::Matchers::BaseMatcher
Instance Method Details
#description ⇒ Object
373 374 375 |
# File 'lib/rspec/sse/matchers.rb', line 373 def description "contain exactly #{@expected.inspect} in any order" end |
#match_condition ⇒ Object
Match if extracted actual values match expected values in any order
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/rspec/sse/matchers.rb', line 353 def match_condition return false unless extract_actual.size == @expected.size matched_indices = {} @expected.each do |expected_item| matched = false extract_actual.each_with_index do |actual_item, index| next if matched_indices[index] if match_items(actual_item, expected_item) matched_indices[index] = true matched = true break end end return false unless matched end true end |