diff --git a/lib/mocha/mockery.rb b/lib/mocha/mockery.rb index 4ea9ea15e..8b245ec4e 100644 --- a/lib/mocha/mockery.rb +++ b/lib/mocha/mockery.rb @@ -87,7 +87,10 @@ def verify(assertion_counter = nil) raise ExpectationErrorFactory.build(message, backtrace) end unless Mocha.configuration.stubbing_method_unnecessarily == :allow - expectations.reject(&:used?).each { |e| on_stubbing_method_unnecessarily(e) } + expectations.reject(&:used?).each do |expectation| + signature_proc = lambda { expectation.method_signature } + check(:stubbing_method_unnecessarily, 'method unnecessarily', signature_proc, expectation.backtrace) + end end end @@ -130,11 +133,6 @@ def on_stubbing(object, method) check(:stubbing_method_on_non_mock_object, 'method on non-mock object', signature_proc) end - def on_stubbing_method_unnecessarily(expectation) - signature_proc = lambda { expectation.method_signature } - check(:stubbing_method_unnecessarily, 'method unnecessarily', signature_proc, expectation.backtrace) - end - attr_writer :logger def logger