How to write specs for already written parts of an application?

Hi,
What should be my approach to write specs for the parts of an
applications
which are already written? How should I start writing tests for those
models, controllers which were not generated using rspec_controller or
rspec_model? Would you please point me to some tutorials for writing
RSpec
tests? Is there any IRC channel for RSpec users?

On Fri, Jan 2, 2009 at 11:54 AM, waseem ahmad [email protected]
wrote:

Hi,
What should be my approach to write specs for the parts of an applications
which are already written? How should I start writing tests for those
models, controllers which were not generated using rspec_controller or
rspec_model? Would you please point me to some tutorials for writing RSpec
tests? Is there any IRC channel for RSpec users?

rspec on freenode

Check out Michael Feathers’ Working Effectively with Legacy Code for
learning how to get untested apps under test.

General idea is to do it gradually over time. When you have a new
requirement, figure out what code needs to change to add that
requirement, and write characterization tests (high level tests using
a tool like Cucumber) that characterize what the application already
does. The WELC book provides strategies for determining which tests to
add, but the idea is to add the least number of tests to cover the
code you want to change, so when you start changing it you have
confidence you’re not breaking things.

Once you have the characterization tests in place, then you drive out
the new code using TDD.

HTH,
David