class Aruba::Matchers::BaseMatcher
Base Matcher
Constants
- UNDEFINED
@api private Used to detect when no arg is passed to `initialize`. `nil` cannot be used because it's a valid value to pass.
Attributes
actual[R]
@private
expected[R]
@private
rescued_exception[R]
@private
Public Class Methods
new(expected = UNDEFINED)
click to toggle source
# File lib/aruba/matchers/base/base_matcher.rb, line 17 def initialize(expected = UNDEFINED) @expected = expected unless UNDEFINED.equal?(expected) end
Public Instance Methods
description_of(object)
click to toggle source
Returns the description of the given object in a way that is aware of composed matchers. If the object is a matcher with a `description` method, returns the description; otherwise returns `object.inspect`.
# File lib/aruba/matchers/base/base_matcher.rb, line 91 def description_of(object) Aruba::Matchers::ObjectFormatter.format(object) end
iterable?()
click to toggle source
# File lib/aruba/matchers/base/base_matcher.rb, line 30 def iterable? @actual.respond_to?(:each_with_index) end
matches?(actual)
click to toggle source
@api private Indicates if the match is successful. Delegates to `match`, which should be defined on a subclass. Takes care of consistently initializing the `actual` attribute.
# File lib/aruba/matchers/base/base_matcher.rb, line 25 def matches?(actual) @actual = actual match(expected, actual) end