Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

A Review of “The RSpec Book” by David Chelimsky

By Peter Cooper / March 14, 2011

The RSpec Book ( by David Chelimsky (plus a cadre of BDD superstars) is a recent release from The Pragmatic Programmers and a handy addition to any TDD-mad or RSpec-using developer's bookshelf. You can buy a copy from,, or direct from the publisher (more expensive but a PDF version is available).

What is The RSpec Book?

The RSpec Book is a 400 page book by David Chelimsky (RSpec's primary maintainer), Dave Astels, Zach Dennis, Aslak Hellesøy (of Cucumber fame), Bryan Helmkamp and Dan North. Its aim is to teach you all about RSpec (RSpec 2.0 - specifically) and BDD (Behavior Driven Development) from the ground up and it promises to "help you write better code, write better tests, and delver better software to your users."

Robert C. Martin (a.k.a. Uncle Bob) kicks off the book with a foreword that warns us of what's to come. He says that the book is a trap and isn't really about RSpec. I won't spoil the whole surprise of his delivery but his general point is that the book is focused on teaching you software craftsmanship using BDD (and testing in general) as the framework for putting together well-crafted software. This point is significant because The RSpec Book focuses on the concepts of BDD just as much as it does on the technicalities of RSpec itself.

A Book of Five Parts

The book starts with an extensive Getting Started section headed by a quick chapter summarizing RSpec and Cucumber before moving on to a suite of walkthrough-style chapters dedicated to building a 'code breaker' game. Acceptance Test-Driven Planning is used which essentially means the acceptance tests are written first in the form of Cucumber features so for two chapters you don't get to see any RSpec at all. Once RSpec comes into the mix, though, things move quickly and mocks (doubles) and stubs are introduced quickly. The 'code breaker' game work then continues for a couple of chapters with a brief detour into refactoring.

The second section of the book - Behavior Driven Development - is made up of two code-free chapters that look at BDD from a higher level. A lot of this portion is quite opinionated but if you want to get an overall feel for the BDD process and how different concepts interlock with it, it's a great primer.

The third section of the book - RSpec - proved to be the real "meat" for me. There are several chapters digging solely into the ins and outs of RSpec 2.0 itself. You learn how to use RSpec from the basics up, working through matchers, best practices, mocks, macros, custom formatters, custom matchers, and how the RSpec toolkit can integrate with other tools (such as TextMate). You basically get a 102 page guide to RSpec 2.0 here and that might be worth the price of admission alone.

Sections dedicated to Cucumber and Rails follow on to close the book. I found the Rails section particularly useful having not previously gotten on to the RSpec 2 bandwagon with Rails 3. There are several chapters that each walk through a particular topic, like view specs, controller specs, and model specs. I didn't want to digest the entire set at once and the structure helped me just dig into the parts I was immediately interested in without following each chapter in order. The large number of short and sweet code examples also helps if you're just scanning through looking for some guidance.

Given the significance of The RSpec Book and its time already spent out "in the wild" I asked my Twitter followers for some second opinions to round things off:

In short, I recommend The RSpec Book. The reviews on Amazon seem to be rather mixed so you might want to check them out to get the bigger picture, but I've found the book to be rather useful with its direct narrative style, logical structure, and vast number of short code examples from which to descry some handy techniques.

Who Should Buy It?

  • Rubyists who want to get up to speed with RSpec 2.0 and, to a lesser extent, Cucumber
  • Rails 3.0 developers who want to learn how to do model, controller, view and integration testing with RSpec 2.0
  • Anyone with a high-level interest in BDD, even if they're not Ruby developers.
  • Anyone who thinks a small press like The Pragmatic Programmers is worth supporting (yes!)

Who Shouldn't Buy It?

  • Anyone expecting a wide overview of TDD and BDD toolsets and libraries. For example, I didn't find any references to Capybara, though Webrat is mentioned.
  • Any existing BDD, RSpec 2 and Cucumber gurus.
  • Die-hard Test::Unit users.

The Chapters

Here's an overview of the Table of Contents to give you a feel for what's covered:

  • Getting Started with RSpec and Cucumber
    • Introduction
    • Hello (and Installation)
    • Describing Features
    • Automating Features with Cucumber
    • Describing Code with RSpec
    • Adding New Features
    • Specifying an Algorithm
    • Refactoring with Confidence
    • Feeding Back What We’ve Learned
  • Behaviour-Driven Development
    • The Case for BDD
    • Writing Software That Matters
  • RSpec
    • Code Examples
    • RSpec::Expectations
    • RSpec::Mocks
    • Tools And Integration
    • Extending RSpec
  • Cucumber
    • Intro to Cucumber
    • Cucumber Detail
  • Behaviour-Driven Rails
    • BDD in Rails
    • Cucumber with Rails
    • Simulating the Browser with Webrat
    • Automating the Browser with Webrat and Selenium
    • Rails Views
    • Rails Controllers
    • Rails Models

How to Get The RSpec Book

If you want a print copy (no Kindle - sorry!), head to,, or your other favorite book retailer. If a PDF, EPUB or Mobi (Kindle) file is more to your taste, the publisher has those for sale directly - super dooplebloops!


  1. Jamie Lawrence says:

    The question I'm struggling with is how does The RSpec Book compare to Eails Test Prescriptions ( also by Pragmatic Programmers? Has anyone had a chance to compare them?

  2. Peter Cooper says:

    I haven't read it but encourage anyone who has to comment :-)

    The only thing I can say is that I'd expect RTP doesn't dig into the high-level BDD talk and doesn't cover RSpec 2 in the same depth separate from Rails.

  3. Peter Aronoff says:

    I think the short version would be something like this: Rails Test Prescriptions is all Rails, and not primarily Rspec. (If anything it's mostly Test::Unit, though Rspec and Cucumber do get a chapter each.) On the other hand, The Rspec Book is not all Rails, but is only Rspec and company. I haven't finished it yet, but four chapters into Rails Test Prescriptions I'm finding it very clear and well-written.

  4. dotemacs says:

    @Jamie Lawrence - I would recommend The Rspec Book over RTS. I'd say that Peter's review of the book is pretty accurate. The book teaches you Rspec 2, but also you pick up why and how those techniques were designed and where they derive from.

    RTS, on the other hand, is more like a quick reference. It covers a wide array of testing toolset, some of it demonstrated with Rails 2 some with Rails 3. Others, just have a couple of pages about them. I'd say that it complements The Rspec Book.

  5. David says:

    Nice review, think im going to get it form my local university library.

  6. Jamie Lawrence says:

    Thanks for the replies... it sounds like The RSpec Book is the one for me. The title really is a bit misleading (and I of course meant *Rails* Test Prescriptions - damn, iPhone autocorrect!)

  7. Lloyd Budd says:

    Peter, it's wonderful to read your thoughts on this book, particularly with there being so few reviews.

    Have you had a chance to read a draft of "Continuous Testing with Ruby: with Ruby, Rails, and JavaScript"? As a novice, on first read through I've found it much more practical->pragmatic. What's the point if not setting up with automation in mind from the start.

    I can't help, but wonder if combined these two books would make a truly great book.

    I plan to reread The RSpec Book, but on first read through I found it too much of the insiders perspective directed at an intermediate to advanced audience -- I'll readily acknowledge the title sets it up to be for a niche audience.

    The Uncle Bob foreword was over the top. It is too too much of the Kool-Aid, which I guess could be a warning for what is to come.

    I'm also disappointed that my questions and comments have had no response on the book's official forum: . I basically gave up on asking them. The sparse discussion there seems focused on code issues with the examples, or upgraded software.

    I think this book has a lot of potential, and I did come away feeling that understanding it will contribute to my success, but I'll have to revisit once I have more experience to see if it then makes more sense to me.

  8. Peter Cooper says:

    @Lloyd: I haven't, unfortunately! I actually get through a rather limited number of books due to the time involved. These tend to be the ones publishers or their PR types either send me automatically or e-mail me about specifically (big tip there for publishers, I like a sob story!)

    Mostly agree with your comments, though I didn't find those elements unfortunate. Perhaps I am a bit too "close" to the topic to see these things as negatives though..

    I'll see if I can get my hands on that other book. It sounds like it might well suit a lot of my readers better.

  9. Jeff Poulton says:

    I have been referencing this book for the past 6-8 months as it worked its way through beta. For better or worse, this book, along with Rasmusson's Agile Samurai, have been instrumental in my BDD/Agile learning curve.

    I appreciate that the Rspec book has examples and sections in plain ruby, as well as providing Rails-specific content. One little gotcha. In the PDF version, the highly useful appendix listing Rspec's built-in matchers is incorrectly nested at the end of the Behavior-Driven Rails section. I tend to refer to this section of the book more than any other, but it's tricky to find.

  10. Mike Bethany says:

    I didn't realize how much RSpec had that I wasn't using till I read the book. That could be seen as a total failure of the documentation (which is pretty weak I think) but luckily the book is more than just a Microsoft-esque reprinting of the help files. It really helped me understand some of the core concepts of BDD while learning how to use RSpec.

    I'd give the book a solid 7 out of 10. It's well worth the price and I would recommend it for a novice BDD'er like myself.

Other Posts to Enjoy

Twitter Mentions