Book Review: The Rspec Book
Reading The Rspec book is a lot like testing itself. A bit of a chore, but in the end you hopefully are better off for it. Additionally, the book covers much more than Rspec, and focuses greatly on behavior-driven development and Cucumber. Finally it is straight from the horse’s mouth, as many of the authors directly contribute (or created) the tools gone over in the book.
The book starts with building a game app and writing tests in it using Cucumber and Rspec. This is helpful for seeing how the two interact, and how test driven development works. Following the sample app, there are a few chapters devoted to talking purely about software development, agile methodologies, and BDD. The book then gets into to the nitty-gritty of Rspec, followed by Cucumber, and then BDD development in Rails. This structure and pacing is a bit tiresome, but I think you could skip around without losing much. For example, if you think you understand Rspec conceptually, but want to understand expectations and before hooks better, you could skip to the Rspec section in the middle.
The authors really shine at explaining Agile methodology and TDD/BDD. If you are looking for a primer, you might skip straight to Chapters 10 and 11 which provide a high level overview of these methodologies.
I have read elsewhere that people find this book outdated, and I have to say I agree. Parts of this book seem to be stuck in past methodology. For example, much of the Rails testing in this book uses Webrat which has been summarily replaced by capybara. Much of the theory remains, it just means that the code itself may not be directly transferable/helpful. On this note, the test focuses heavily on Cucumber, which is rapidly being replaced by Spinach for Ruby BDD. Theory stays the same, but code may be different. My finally note on this topic: the book does does not appear to cover “expect” method assertions. This makes sense because I do not believe this format came to prominence until well after this book was published.
Overall, I would recommend this book in spite of a few antiquated methods. It provides a high level understanding of Agile and testing. Moreover, I know that it has made me a better tester and thinking in the form of testing.
Where I see value:
- deeper understanding of how Rspec patterns, and therefore better testing
- better understanding of Agile methodology and behavior driven development
Specific areas of interest:
If you are a Ruby or Rails Developer looking for the best real world help:
- Chapters 1-9 for Rspec/Cucumber overview
- Chapters 12-14 for Rspec nitty gritty that you might actually use on a daily basis
- Chapters 19,20,23-25 for testing in Rails applications.
[See my Rspec Notes for more highlights]({% post_url 2013-09-14-rspec-notes %})