Skip to content

Instantly share code, notes, and snippets.

@leonid-shevtsov
Last active September 5, 2017 09:35
Show Gist options
  • Save leonid-shevtsov/7d31979e1f6fca87b21b680e512ba255 to your computer and use it in GitHub Desktop.
Save leonid-shevtsov/7d31979e1f6fca87b21b680e512ba255 to your computer and use it in GitHub Desktop.

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