Class: SpecCombos::AndMatcher

Inherits:
Object
  • Object
show all
Includes:
MatcherCombiner, MatcherCombiner::And
Defined in:
lib/spec_combos/and_matcher.rb

Overview

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

Instance Method Summary collapse

Methods included from MatcherCombiner::And

#match_result

Methods included from MatcherCombiner

#failure_message_for_should, #failure_message_for_should_not, #matches?

Constructor Details

#initialize(*matchers) ⇒ AndMatcher

Returns a new instance of AndMatcher.



8
9
10
# File 'lib/spec_combos/and_matcher.rb', line 8

def initialize(*matchers)
  @matchers = matchers
end

Instance Method Details

#descriptionObject



12
13
14
15
16
17
18
19
20
# 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