class RSpec::Mocks::VerifyingMessageExpectation
have the correct arity.
message being expected, so that it can verify that any expectations
A message expectation that knows about the real implementation of the
def ensure_arity!(actual)
def ensure_arity!(actual) return if method_reference.nil? method_reference.when_defined do |method| calculator = ArityCalculator.new(method) unless calculator.within_range?(actual) # Fail fast is required, otherwise the message expecation will fail # as well ("expected method not called") and clobber this one. @failed_fast = true @error_generator.raise_arity_error(calculator, actual) end end end
def initialize(*args)
def initialize(*args) super end
def with(*args, &block)
def with(*args, &block) unless ArgumentMatchers::AnyArgsMatcher === args.first expected_arity = if ArgumentMatchers::NoArgsMatcher === args.first 0 elsif args.length > 0 args.length else # No arguments given, this will raise. super end ensure_arity!(expected_arity) end super end