class SpecCombos::AndMatcher

Matcher to verify that an item matches all matchers in a list

Public Class Methods

new(*matchers) click to toggle source
# File lib/spec_combos/and_matcher.rb, line 8
def initialize(*matchers)
  @matchers = matchers
end

Public Instance Methods

description() click to toggle source
# File lib/spec_combos/and_matcher.rb, line 12
def description
  descriptions = @matchers.map &:description

  if descriptions.size <= 2
    descriptions.join(" and ")
  else
    descriptions[0..-2].join(", ") + " and " + descriptions.last
  end
end

Private Instance Methods

failure_summary_for_should() click to toggle source
# File lib/spec_combos/and_matcher.rb, line 31
def failure_summary_for_should
  "expected #{actual} to #{description}, but:"
end
failure_summary_for_should_not() click to toggle source
# File lib/spec_combos/and_matcher.rb, line 35
def failure_summary_for_should_not
  "expected #{actual} not to #{description}, but it is all:"
end
perform_matches(actual) click to toggle source
# File lib/spec_combos/and_matcher.rb, line 24
def perform_matches(actual)
  @matchers.map do |matcher|
    { matcher: matcher,
      match: matcher.matches?(actual)}
  end
end