class RSpec::Matchers::BuiltIn::Match

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

Public Class Methods

# File rspec-expectations/lib/rspec/matchers/built_in/match.rb, line 8
def initialize(expected)
  super(expected)

  @expected_captures = nil
end

Public Instance Methods

@api private @return [String]

# File rspec-expectations/lib/rspec/matchers/built_in/match.rb, line 15
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

@api private @return [Boolean]

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

@api private @return [String]

# File rspec-expectations/lib/rspec/matchers/built_in/match.rb, line 38
def failure_message
  if Array === expected && !(actual.respond_to?(:to_a) || actual.respond_to?(:to_ary))
    return "expected a collection that can be converted to an array with " \
           "`#to_ary` or `#to_a`, but got #{actual_formatted}"
  end

  super
end

Used to specify the captures we match against @return [self]

# File rspec-expectations/lib/rspec/matchers/built_in/match.rb, line 31
def with_captures(*captures)
  @expected_captures = captures
  self
end