Ruby On Rails Lesson
Introduction to Cucumber (Optional)
Having finished the foundation of the sample application’s authentication system, we’re going to take this opportunity to show how to write signin tests using Cucumber, a popular tool for behavior-driven development that enjoys significant popularity in the Ruby community. This section is optional and can be skipped without loss of continuity.
Cucumber allows the definition of plain-text stories describing application behavior. Many Rails programmers find Cucumberespecially convenient when doing client work; since they can be read even by non-technical users, Cucumber tests can be shared with (and can sometimes even be written by) the client. Of course, using a testing framework that isn’t pure Ruby has a downside, and I find that the plain-text stories can be a bit verbose. Nevertheless, Cucumber does have a place in the Ruby testing toolkit, and I especially like its emphasis on high-level behavior over low-level implementation.
Since the emphasis in this book is on RSpec and Capybara, the presentation that follows is necessarily superficial and incomplete and will be a bit light on explanation. Its purpose is just to give you a taste of Cucumber (crisp and juicy, no doubt)—if it strikes your fancy, there are entire books on the subject waiting to satisfy your appetite. (I particularly recommend The RSpec Book by David Chelimsky and Rails 3 in Action by Ryan Bigg and Yehuda Katz, and The Cucumber Book by Matt Wynne and Aslak Hellesøy.)