philou/spec_combos

View on GitHub
lib/spec_combos/any_matcher.rb

Summary

Maintainability
A
25 mins
Test Coverage
module SpecCombos

  # Matcher to verify that all items match something else
  class AnyMatcher
    include MatcherCombiner
    include MatcherCombiner::Or
    include CollectionMatcher

    private

    def short_description
      "have any that"
    end

    def failure_summary_for_should
      "expected #{actual_items} to #{description}, but none were:"
    end

    def failure_summary_for_should_not
      "expected #{actual_items} not to #{description}, but the following were:"
    end
  end
end

def any_(&item_matcher_proc)
  SpecCombos::AnyMatcher.new(&item_matcher_proc)
end
alias :have_any_that :any_