Learning to Use RSpec

Most of the “Intro to Rails” books show how to develop web apps by writing code and then tests. (The more sophisticated books advise to write the tests and then write the code.) The books give good examples of using the built-in Test::Unit facility. But many experienced Rails developers are now using RSpec. There’s only one book I’ve seen that covers RSpec and that’s Obie Fernandez’s The Rails Way. The book doesn’t really explain why so many developers are moving to RSpec; for that, see an article by Dan North or an article by Dave Astels. They argue that we should be writing specifications, not tests.

There are a few tutorials that introduce RSpec, notably a series on the O’Reilly Network on Behavior Driven Development Using Ruby, with Part 1, Part 2, and Part 3. There are also four Peepcode screencasts, starting with RSpec Basics.

RSpec is in the midst of rapid development and there are enough differences between RSpec version 1.1.0, which introduced new functionality (“user stories’), and earlier versions which are covered in the tutorials, that it is possible to get confused.

With so much rapid development of RSpec, the best place to get guidance is the Rspec Users mailing list.

Just a note, you might want to install the Textmate bundle for RSpec.


Comments are closed.

%d bloggers like this: