class RSpec::Matchers::BuiltIn::StartAndEndWith

Public Class Methods

new(*expected) click to toggle source
# File lib/rspec/matchers/built_in/start_and_end_with.rb, line 5
def initialize(*expected)
  @expected = expected.length == 1 ? expected.first : expected
end

Public Instance Methods

failure_message_for_should() click to toggle source
# File lib/rspec/matchers/built_in/start_and_end_with.rb, line 18
def failure_message_for_should
  "expected #{@actual.inspect} to #{self.class.name.split('::').last.sub(/With/,'').downcase} with #{@expected.inspect}"
end
failure_message_for_should_not() click to toggle source
# File lib/rspec/matchers/built_in/start_and_end_with.rb, line 22
def failure_message_for_should_not
  "expected #{@actual.inspect} not to #{self.class.name.split('::').last.sub(/With/,'').downcase} with #{@expected.inspect}"
end
matches?(actual) click to toggle source
# File lib/rspec/matchers/built_in/start_and_end_with.rb, line 9
def matches?(actual)
  @actual = actual.respond_to?(:[]) ? actual : (raise ArgumentError.new("#{actual.inspect} does not respond to :[]"))
  begin
    @expected.respond_to?(:length) ? subset_matches?(@expected, @actual) : element_matches?(@expected, @actual)
  rescue ArgumentError
    raise ArgumentError.new("#{actual.inspect} does not have ordered elements")
  end
end