From 0532ada9d9b8246ad223c540626b46b16283deb4 Mon Sep 17 00:00:00 2001 From: Nitish Rathi Date: Wed, 25 Dec 2019 23:51:41 +0000 Subject: [PATCH] Inline on_stubbing_method_unnecessarily This method was only being called from one place. --- lib/mocha/mockery.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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