Webrat: Rails Acceptance Testing Evolved - RailsConf

A robust suite of acceptance tests ensures your Rails app stays working giving you extreme freedom to refactor.

Unfortunately, traditional full-stack acceptance testing of web-based applications has centered on in-browser solutions like Selenium and Watir that immediately present challenges like speed, timing/waiting and sharing data across processes, all through a relatively clunky API designed without Ruby in mind. Getting started was troublesome, and keeping things running smoothly was a constant concern.

Webrat, a Ruby DSL for interaction with web applications, changes the acceptance testing ROI equation. By implementing an invisible, fast browser simulator you can use from within your test framework of choice (Test::Unit, RSpec, Shoulda or Cucumber), it sidesteps most of Selenium’s drawbacks while retaining the coverage value.

Recently, seamless Webrat integration featured prominently in the Merb 1.0 release as the recommended approach for high level testing, a theme that will be a part of the Rails 3 push. Webrat is fast becoming the ubiquitous API for driving web applications from Ruby with it’s support for different adapters like Selenium, Mechanize and Celerity.

This talk, delivered by the maintainer of Webrat, will describe the value of acceptance testing for Rails apps, common pitfalls, and Webrat’s solutions. We’ll look at techniques for writing maintainable acceptance tests, and maximizing their value over the lifespan of an application. Finally, we’ll explore advanced techniques like applying Webrat to ease some of the pain of in-browser testing when it can’t be avoided (JavaScript/AJAX, primarily).