module SpecCombos::CollectionMatcher
Mixin for the :and and :any collection matchers
Public Class Methods
new(&item_matcher_proc)
click to toggle source
# File lib/spec_combos/collection_matcher.rb, line 6 def initialize(&item_matcher_proc) @item_matcher_proc = item_matcher_proc end
Public Instance Methods
description()
click to toggle source
# File lib/spec_combos/collection_matcher.rb, line 10 def description "#{short_description} #{new_matcher.description}" end
Private Instance Methods
actual_items()
click to toggle source
# File lib/spec_combos/collection_matcher.rb, line 34 def actual_items @actual end
failure_message_prefix(failure)
click to toggle source
# File lib/spec_combos/collection_matcher.rb, line 30 def failure_message_prefix(failure) "[#{failure[:index]}] (#{failure[:item]}): " end
new_matcher()
click to toggle source
# File lib/spec_combos/collection_matcher.rb, line 26 def new_matcher @item_matcher_proc.call end
perform_matches(actual_items)
click to toggle source
# File lib/spec_combos/collection_matcher.rb, line 16 def perform_matches(actual_items) actual_items.each_with_index.map do |item, index| matcher = new_matcher { index: index, item: item, matcher: matcher, match: matcher.matches?(item)} end end