Calling Private Methods Without Losing Sleep at Night
The only problem? The method I need,
ActionDispatch::FileHandler#find_fileis private, meaning that I really “shouldn’t” be calling it. But also, it’s a free country, so whatever. I wrote this and it worked:
This is the beauty of programming in Ruby. You are trusted with sharp knives to accept (and mitigate) your own risks.
Of course, I could write a test to ensure this method still works, but I didn’t want to give this method even more of my time. So instead, I codified this assumption in an initializer:
Writing a test that will fail is routine to me. It feels like an understanding unlock to move that failure from test time to boot time. A failing test can be ignored as flaky. An app that won’t boot demands attention for resolution.