On the dangers of changing mixins


Mostly writing this as a PSA, please be careful when adding new methods to common mixins or things pulled in to common mixins. Because of how Ruby encapsulation works, even something marked private in the module still ends up dumped into the namespace of every class using the mixin. I’ll put up PRs to clean up some of the big ones but just going forward, please be very very careful adding new instance methods to stuff like Mixin::ShellOut and Mixin::PathSanity. The usual fix for needing test injection helpers or code reuse stuff is to declare the helper via “def self.whatver” and then call it like “ShellOut.whatever”. But then be aware that subclasses can’t replace that behavior, so yeah, just be careful :slight_smile:



Along the lines of this topic, can you provide some before/after examples. That will help others going forward to not fall into the same issues.