On RSpec

Tuesday, 5th April 2011

Apparently, DHH has made disparaging comments about RSpec and Cucumber.

Obviously, everybody’s perspective is shaped by their experience, but I have to admit to being initially surprised that someone of his calibre would feel that way. But then it occurred to me that David doesn’t actually live in the “real world!”1

In David’s world, he’s the end user (or the interpreter and decision maker on behalf of the end user’s needs), the business analyst, the architect, the designer and the developer. He decides the spec. He invents the spec. To him, the spec is absolutely clear, he doesn’t need to clarify it with the customer: he is the customer.

However if, like me, you’re one of the vast majority who develops for “normal” business customers, writing enterprise software for large corporations, you’ll know that decent specs can actually be hard to come by.

More often than you’d like, the “specs” you get are woolly, poorly analysed and equally poorly worded. You find yourself trying to interpret a terse bug report or enhancement request, written by a BA on the frontline in frazzled firefighting mode.

This is where RSpec and Cucumber comes into its own.

If you can get your BA to write the Cucumber script for you, so much the better, but if you can’t it doesn’t take much to write it yourself and get your BA to verify it. You can then drop into RSpec, write your specs, and verify those with the BA.

Usually, the process allows you to hammer out the details of the requirement clearly and succinctly and then start developing the solution knowing that you’re supported by a requirement definition that is also the test.

RSpec and Cucumber serve as the elaboration mechanism, the specification documentation, the testing tool and the acceptance test, all in one, and in the “real world” of enterprise application development, that’s worth far more than the supposed succinctness of tools like Test::Unit.

To me, having all of what RSpec and Cucumber gives you in a few lines of descriptive documentation and code is the very definition of succinct.

David’s fortunate that he doesn’t need the support of a tool like RSpec. But for the rest of us, RSpec and Cucumber provide, and will continue to provide, unbelievable support and clarity.

  1. Of course David’s world is just as real, it’s just a different real to mine!