class RSpec::Mocks::Proxy

def find_best_matching_expectation_for(method_name)

def find_best_matching_expectation_for(method_name)
  first_match = nil
  method_double[method_name].expectations.each do |expectation|
    next unless yield expectation
    return expectation unless expectation.called_max_times?
    first_match ||= expectation
  end
  first_match
end