class RSpec::Matchers::BuiltIn::Match

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

Public Instance Methods

description() click to toggle source

@api private @return [String]

# File lib/rspec/matchers/built_in/match.rb, line 10
def description
  "match #{surface_descriptions_in(expected).inspect}"
end
diffable?() click to toggle source

@api private @return [Boolean]

# File lib/rspec/matchers/built_in/match.rb, line 16
def diffable?
  true
end

Private Instance Methods

can_safely_call_match?(expected, actual) click to toggle source
# File lib/rspec/matchers/built_in/match.rb, line 28
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
match(expected, actual) click to toggle source
# File lib/rspec/matchers/built_in/match.rb, line 22
def match(expected, actual)
  return true if values_match?(expected, actual)
  return false unless can_safely_call_match?(expected, actual)
  actual.match(expected)
end