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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
waseem ahmad (Guest)
on 2009-01-02 19:57
(Received via mailing list)
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?
David C. (Guest)
on 2009-01-02 20:11
(Received via mailing list)
On Fri, Jan 2, 2009 at 11:54 AM, waseem ahmad 
<removed_email_address@domain.invalid>
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
This topic is locked and can not be replied to.