Lint/DuplicateMethods false positive when using alias_method
to change/change back a method
#11273
Labels
alias_method
to change/change back a method
#11273
This is something we sometimes do as a test helper method to ensure some sort of behavior out of a method in the class to be tested. Imagine, for example, we wanted
save
in the tested class to always raise an error when called, but we also don't want it to stay modified:If you call
rubocop --only Lint/DuplicateMethods
on that snippet, you get a false positive for the "second" definition ofsave
inside theensure
block.https://wasabigeek.com/blog/practical-metaprogramming-in-ruby-minitest-mock/ outlines a similar form of this.
Expected behavior
Should allow multiple
alias_method
definitions of the same name if they happen in different scopes.Actual behavior
See above.
Steps to reproduce the problem
See example snippet and command above.
RuboCop version
The text was updated successfully, but these errors were encountered: