module SpecCombos::MatcherCombiner

Constants

INDENT_WIDTH
MATCHING
NOT_MATCHING

Attributes

actual[R]

Public Instance Methods

failure_message_for_should() click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 23
def failure_message_for_should
  failure_message(MATCHING, failure_summary_for_should)
end
failure_message_for_should_not() click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 27
def failure_message_for_should_not
  failure_message(NOT_MATCHING, failure_summary_for_should_not)
end
matches?(actual) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 17
def matches?(actual)
  @actual = actual
  @match_details = perform_matches(actual)
  match_result
end

Private Instance Methods

explain(failure) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 48
def explain(failure)
  failure_message_prefix(failure) + message(failure)
end
explanations(expected_match) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 45
def explanations(expected_match)
  matches(expected_match).map {|failure| explain(failure)}
end
failure_message(expected_match, summary) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 39
def failure_message(expected_match, summary)
  summary + "\n" + indent(full_explanation(expected_match), INDENT_WIDTH)
end
failure_message_prefix(failure) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 51
def failure_message_prefix(failure)
  ""
end
full_explanation(expected_match) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 42
def full_explanation(expected_match)
  explanations(!expected_match).join("\n")
end
indent(text, tabs) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 69
def indent(text, tabs)
  text.gsub(/^/, ' ' * tabs)
end
matches(expected_match) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 65
def matches(expected_match)
  @match_details.find_all {|detail| detail[:match] == expected_match}
end
message(failure) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 54
def message(failure)
  failure[:matcher].send(message_selector(failure))
end
message_selector(failure) click to toggle source
# File lib/spec_combos/matcher_combiner.rb, line 57
def message_selector(failure)
  if failure[:match]
    :failure_message_for_should_not
  else
    :failure_message_for_should
  end
end