Apply Behavior Driven Development to Ruby on Rails with Rspec

by Saurabh Bhatia

Learn how to do apply Behavior Driven Development (BDD) to your Rails projects with the Ruby-based BDD framework RSpec.

Applying the Behavior Driven Development (BDD) methodology with a Ruby-based BDD framework allows you to write system requirements in a Ruby format first and then write Ruby code for the particular features of those requirements. Because the Ruby format is similar to plain English, business analysts and the people gathering the requirements can participate in the development process.

A few different Ruby-based BDD frameworks are available. RSpec, Cucumber, and Shoulda are the most popular. Find out how RSpec works by using the use case of an employee information manager.

BDD mandates that you write tests for each step of the process, which leads to cleaner code. The BDD process begins with the development team creating a scenario, for which they describe each feature. The initial scenario inevitably fails. The team subsequently defines each step (iterative test) and writes the application code for each feature. They also refactor the code when the scenario passes each step.

Read the full story at Web Developer's Virtual Library:
Apply Behavior Driven Development to Ruby on Rails with Rspec

This article was originally published on Friday Feb 5th 2010
Mobile Site | Full Site