class RSpec::Mocks::TargetBase

Public Class Methods

delegate_to(matcher_method, options = {}) click to toggle source
# File lib/rspec/mocks/targets.rb, line 11
      def self.delegate_to(matcher_method, options = {})
        method_name = options.fetch(:from) { :to }
        class_eval(<<-RUBY)
        def #{method_name}(matcher, &block)
          unless Matchers::Receive === matcher
            raise UnsupportedMatcherError, "only the `receive` matcher is supported " +
              "with `\#{expression}(...).\#{#{method_name.inspect}}`, but you have provided: \#{matcher}"
          end

          matcher.__send__(#{matcher_method.inspect}, @target, &block)
        end
        RUBY
      end
disallow_negation(method) click to toggle source
# File lib/rspec/mocks/targets.rb, line 25
def self.disallow_negation(method)
  define_method method do |*args|
    raise NegationUnsupportedError,
      "`#{expression}(...).#{method} receive` is not supported since it " +
      "doesn't really make sense. What would it even mean?"
  end
end
new(target) click to toggle source
# File lib/rspec/mocks/targets.rb, line 7
def initialize(target)
  @target = target
end

Private Instance Methods

expression() click to toggle source
# File lib/rspec/mocks/targets.rb, line 35
def expression
  self.class::EXPRESSION
end