TDD can help you write cleaner code, and help you code DRYer.
- Write a test that fails (a red test)
- Make the code work (runs green)
- Refactor. Eliminate redundancy (purple)
and repeat the cycle.
- Ensures that your test is written correctly.
- Ensures that you actually write tests for all of your code.
- Leads to better design.
Some people thinks this is the worst way to write code:
Martin Fowler
https://martinfowler.com/articles/is-tdd-dead/
dhh
http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html
https://en.wikipedia.org/wiki/Fizz_buzz
https://www.codecademy.com/courses/ruby-beginner-en-Zjd2y/0/1
https://www.amazon.com/Refactoring-Ruby-Addison-Wesley-Professional/dp/0321984137