module RSpec::Matchers::BaseMatcher

@api private

Used internally as a base class for matchers that ship with rspec-expectations.

### Warning:

This class is for internal use, and subject to change without notice. We strongly recommend that you do not base your custom matchers on this class. If/when this changes, we will announce it and remove this warning.

Attributes

actual[R]
expected[R]
rescued_exception[R]

Public Class Methods

new(expected=nil) click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 18
def initialize(expected=nil)
  @expected = expected
end

Public Instance Methods

==(other) click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 51
def ==(other)
  matches?(other)
end
description() click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 43
def description
  expected ? "#{name_to_sentence} #{expected.inspect}" : name_to_sentence
end
diffable?() click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 47
def diffable?
  false
end
failure_message_for_should() click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 35
def failure_message_for_should
  "expected #{actual.inspect} to #{name_to_sentence}#{expected_to_sentence}"
end
failure_message_for_should_not() click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 39
def failure_message_for_should_not
  "expected #{actual.inspect} not to #{name_to_sentence}#{expected_to_sentence}"
end
match_unless_raises(exception=Exception) { || ... } click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 26
def match_unless_raises(exception=Exception)
  begin
    yield
    true
  rescue exception => @rescued_exception
    false
  end
end
matches?(actual) click to toggle source
# File lib/rspec/matchers/base_matcher.rb, line 22
def matches?(actual)
  @actual = actual
end