It is hard to underestimate a value and importance of automated tests. Creating confidence about if the code works the right way and thus enabling safe refactoring is just one thing
There's an interesting way to create customizable modules in Ruby that is not well known, which I discussed at a talk at this year's RubyKaigi conference in Hiroshima
The initial motivation behind this gem was to have a tool that would make it possible to serialize Ruby objects to JSON format outside of the view context