Advanced Rails - Building Industrial-Strength Web Apps in Record Time

(Tuis.) #1

322 | Chapter 10: Large Projects


The most popular continuous integration framework is CruiseControl, which started
as a Java project. It has since been ported to .NET and Ruby. ThoughtWorks main-
tains the Ruby port, CruiseControl.rb (http://cruisecontrolrb.thoughtworks.com/). It
runs in the background and monitors the repository every 30 seconds for commits
(the interval is configurable). When a new version is detected, it checks it out into a
working directory and runs the tests with Rake. If there are failures or errors, a fail-
ure email is sent out. (Likewise, if the build was broken but is now fixed, a “fixed”
email is sent.) CruiseControl.rb also provides a neat web interface to view test
progress and results for the latest and previous builds.


Closely related is the ZenTest suite of tools by Ryan Davis.*ZenTest consists of five
tools that help with test coverage, especially under Rails applications. The documen-
tation tells the full story, but the most compelling part of this suite isautotest. This
allows an even shorter cycle time than continuous integration tools. Although the
method is similar to continuous integration, the AutoTest tools are used more for
development (to shorten the cycles between writing code and testing it) than for con-
tinuous integration (which is more of a safety net to prevent obviously bad code from
being deployed).


AutoTest sits in the background and watches the files in a Rails project. When any
file is changed, AutoTest runs the appropriate tests immediately. It is pretty smart
about which tests need to be run, and even watches test fixtures and other dependen-
cies for changes. If you follow the test-driven development methodology, running
AutoTest is a great way to force yourself to stay green. Get started with the
following:


$ sudo gem install ZenTest
$ cd my_rails_app
$ autotest -rails

Further Reading

There are many resources, both free and paid, for learning the version control sys-
tems mentioned in this chapter. For Subversion, there is Version Control with Sub-
version (http://svnbook.red-bean.com/), which is available both for free online and as
a print book from O’Reilly. Also available is Pragmatic Version Control Using Sub-
version (http://pragmaticprogrammer.com/titles/svn2/index.html), which is more of a
tutorial than a reference.


CVS has similar options available. The book Open Source Development with CVS is
available under a GPL license online athttp://cvsbook.red-bean.com/. The print book
is also distributed by O’Reilly. The Pragmatic Programmers’ offering is Pragmatic Ver-
sion Control Using CVS (information available athttp://pragmaticprogrammer.com/
starter_kit/vcc/index.html).


*http://www.zenspider.com/ZSS/Products/ZenTest/

Free download pdf