Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Code that does not run is code that rots

In Ruby, there is absolutely no guarantee that a method's declared signature will match the call signature. The only practical way to ensure this is to execute the call.

Thus, if you have code that is not covered by unit tests, you rely on manual testing - and production - to check that it even links, let alone does what you expect.

From my experience with explicit typing, it eliminates a huge class of refactoring mistakes, where you forget to update a method or a call signature. In Ruby, instead of explicit typing, we have unit tests.

This, to me, is the big reason to write unit tests in Ruby - not because it's more productive, or makes for better code. Code that verifiably links is reason enough to write them.

Whenever you write code, you should also write a test that runs that code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.