Sha256: f1cbef80638a3ac9065017b554dc6febbacbf4c0ec175631ddbe5489230e3efd
Contents?: true
Size: 919 Bytes
Versions: 2
Compression:
Stored size: 919 Bytes
Contents
module SpecCombos # Matcher to verify that an item matches all matchers in a list class AndMatcher include MatcherCombiner include MatcherCombiner::And def initialize(*matchers) @matchers = matchers end def description descriptions = @matchers.map &:description if descriptions.size <= 2 descriptions.join(" and ") else descriptions[0..-2].join(", ") + " and " + descriptions.last end end private def perform_matches(actual) @matchers.map do |matcher| { matcher: matcher, match: matcher.matches?(actual)} end end def failure_summary_for_should "expected #{actual} to #{description}, but:" end def failure_summary_for_should_not "expected #{actual} not to #{description}, but it is all:" end end end def and_(*matchers) SpecCombos::AndMatcher.new(*matchers) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spec_combos-0.3.0 | lib/spec_combos/and_matcher.rb |
spec_combos-0.2.0 | lib/spec_combos/and_matcher.rb |