Hello, Ruby enthusiast! Hello, BDD enthusiast! Welcome to this journey, line by line and test by test, using the Behavior-Driven Development technique on an interesting project: a War dice simulation!
I wrote this tiny book to learn BDD and RSpec myself. I wanted to start with a small example, and, if possible, a fun one too. Then I thought: Why not roll some dice? Why not roll the dice from the game War? And here you are: learning BDD by playing dice!
The app we’ll create together uses two classes: Dice and WarDice.
In the first chapter, I start building the RSpec file for the Dice class alongside the Dice class itself, step by step, until all the tests pass.
In the second chapter, I continue with the WarDice class, which simulates each die in the game War!
Finally, in the third chapter, I use the classes in a fun Shoes application.
The philosophy of this book is to learn by making fun things. In one word: experimentation. I hope you enjoy this simple but also instructive book.
The tests used in this book aren’t a silver bullet. They’re just one possibility among many. As I said, I wrote it to learn RSpec. You can send suggestions, clone the project, modify it, and code it in other ways. Who knows—maybe we’ll play together in version 2.0 of this book :).
Now, just read the book and have fun!
You can download the complete source code for the application here:
http://github.com/valeriofarias/shoes-war-dice/tree
You can download the complete book text and source code here: