Skip to content

Commit

Permalink
Inline on_stubbing_method_unnecessarily
Browse files Browse the repository at this point in the history
This method was only being called from one place.
  • Loading branch information
nitishr authored and floehopper committed Feb 10, 2020
1 parent 365ce92 commit 0532ada
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/mocha/mockery.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0532ada

Please sign in to comment.