class RSpec::Matchers::BuiltIn::Match

Not intended to be instantiated directly.
Provides the implementation for ‘match`.
@api private

def can_safely_call_match?(expected, actual)

def can_safely_call_match?(expected, actual)
  return false unless actual.respond_to?(:match)
  !(RSpec::Matchers.is_a_matcher?(expected) &&
    (String === actual || Regexp === actual))
end

def description

Returns:
  • (String) -

Other tags:
    Api: - private
def description
  if @expected_captures && @expected.match(actual)
    "match #{surface_descriptions_in(expected).inspect} with captures #{surface_descriptions_in(@expected_captures).inspect}"
  else
    "match #{surface_descriptions_in(expected).inspect}"
  end
end

def diffable?

Returns:
  • (Boolean) -

Other tags:
    Api: - private
def diffable?
  true
end

def initialize(expected)

def initialize(expected)
  super(expected)
  @expected_captures = nil
end

def match(expected, actual)

def match(expected, actual)
  return match_captures(expected, actual) if @expected_captures
  return true if values_match?(expected, actual)
  return false unless can_safely_call_match?(expected, actual)
  actual.match(expected)
end

def match_captures(expected, actual)

def match_captures(expected, actual)
  match = actual.match(expected)
  if match
    match = ReliableMatchData.new(match)
    if match.names.empty?
      values_match?(@expected_captures, match.captures)
    else
      expected_matcher = @expected_captures.last
      values_match?(expected_matcher, Hash[match.names.zip(match.captures)]) ||
        values_match?(expected_matcher, Hash[match.names.map(&:to_sym).zip(match.captures)]) ||
        values_match?(@expected_captures, match.captures)
    end
  else
    false
  end
end

def with_captures(*captures)

Returns:
  • (self) -
def with_captures(*captures)
  @expected_captures = captures
  self
end