Class: Crspec::Matchers::EndWithMatcher

Inherits:
BaseMatcher show all
Defined in:
lib/crspec/matchers.rb

Instance Attribute Summary

Attributes inherited from BaseMatcher

#actual, #expected

Instance Method Summary collapse

Methods inherited from BaseMatcher

#and, #failure_message_when_negated, #initialize, #or

Constructor Details

This class inherits a constructor from Crspec::Matchers::BaseMatcher

Instance Method Details

#failure_messageObject



580
581
582
# File 'lib/crspec/matchers.rb', line 580

def failure_message
  "Expected #{@actual.inspect} to end with #{@expected.inspect}"
end

#matches?(actual) ⇒ Boolean

Returns:

  • (Boolean)


569
570
571
572
573
574
575
576
577
578
# File 'lib/crspec/matchers.rb', line 569

def matches?(actual)
  @actual = actual
  if actual.respond_to?(:end_with?)
    actual.end_with?(@expected)
  elsif actual.is_a?(Array)
    actual.last(Array(@expected).size) == Array(@expected)
  else
    false
  end
end