class RSpec::Matchers::BuiltIn::StartOrEndWith

Not intended to be instantiated directly.
Base class for the ‘end_with` and `start_with` matchers.
@api private

def description

Returns:
  • (String) -

Other tags:
    Api: - private
def description
  return super unless Hash === expected
  english_name = EnglishPhrasing.split_words(self.class.matcher_name)
  description_of_expected = surface_descriptions_in(expected).inspect
  "#{english_name} #{description_of_expected}"
end

def failure_message

Returns:
  • (String) -

Other tags:
    Api: - private
def failure_message
  super.tap do |msg|
    if @actual_does_not_have_ordered_elements
      msg << ", but it does not have ordered elements"
    elsif !actual.respond_to?(:[])
      msg << ", but it cannot be indexed using #[]"
    end
  end
end

def initialize(*expected)

def initialize(*expected)
  @actual_does_not_have_ordered_elements = false
  @expected = expected.length == 1 ? expected.first : expected
end

def match(_expected, actual)

def match(_expected, actual)
  return false unless actual.respond_to?(:[])
  begin
    return true if subsets_comparable? && subset_matches?
    element_matches?
  rescue ArgumentError
    @actual_does_not_have_ordered_elements = true
    return false
  end
end

def subsets_comparable?

def subsets_comparable?
  # Structs support the Enumerable interface but don't really have
  # the semantics of a subset of a larger set...
  return false if Struct === expected
  expected.respond_to?(:length)
end