Learn Ruby with TDD
Last updated
Last updated
⚠ This is a work in progress by ! ⚠
This book aims to teach you Ruby and Test-Driven Development.
Since we use Ruby, it's inevitable that we also talk about Object-Oriented Programming (OOP). Also, as we use TDD, it's inevitable that we're going to talk about Software Design.
Ruby has an elegant syntax that is natural to read and easy to write. It offers an extremely productive ecosystem where we can quickly build a product and put it online.
My main reasons to use TDD are:
Promotes a better software design
Facilitates refactoring
Decrease bugs (and time spent with debugging)
Faster development
And currently, there's an even stronger reason to use TDD:
In the current AI era TDD is more valuable than ever.
With AIs writing code much faster than humans, such activity becomes cheaper. This leads me to a conclusion that the real value is less in the code, and more in the tests. Your ability to convert real world requirements into executable tests will make you more productive and a valuable professional.
Explore the Ruby language by writing tests.
Get a solid grounding with TDD.
Strengthen your knowledge of OOP
Be confident that you'll be able to start writing robust, well-tested software in Ruby.
The chapters are presented in a sequence where the Ruby features are introduced and used to create a program. The implementation is always driven by tests, reinforcing the TDD cycle, and with an Object-Oriented approach.
Initially the TDD cycle may seem tedious, but as you progress through the book you'll see how productive it is to get instant feedback on your work.
You'll notice that the first programs are really simple. That's intentional. The greatest value will be in the way we solve the problems. The thought process, the tools we use, the tests we write, the way we organize our code...
If I used "real world problems", we would need to spend brain power understanding the problem's domain and then learn the techniques. That would be tiresome and confusing. By keeping the problems simple, I'm sure you'll find a way to adapt the techniques to the "real world problem" you have at hand.
People who are interested in picking up Ruby.
People who already know some Ruby but want to explore testing more.
I assume you already wrote some code (any language) and understand the basic concepts of algorithms.
It's also expected that you're comfortable using the terminal (or at least not scared to use it).
A computer with a Unix-like operating system (Linux, MacOS or Windows with WSL)
Installed Ruby (3.1+)
A text editor
A terminal
Open issues or submit Pull Requests in .
This book is inspired by the awesome , by . If you're interested in Golang, you should check that!