class RSpec::Matchers::BuiltIn::StartOrEndWith

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

Public Class Methods

# File rspec-expectations/lib/rspec/matchers/built_in/start_or_end_with.rb, line 8
def initialize(*expected)
  @actual_does_not_have_ordered_elements = false
  @expected = expected.length == 1 ? expected.first : expected
end

Public Instance Methods

@api private @return [String]

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

@api private @return [String]

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