I first started learning ruby on rails a couple of years ago and did a
small
project first then started a huge project which is just now in beta.
I’m
the only developer for my company so the big project kept getting put on
the
back burner to do smaller projects that pay the bills now. I have
actually
worked on the large project off and on for about a year. Since then
I’ve
learned a lot of better ways to do things and I’ve also upgraded rails a
couple of times (I’m currently running 1.2.5 on this app).
One of the things I’ve started doing since beginning this project is
behavior driven development. Here is my confession. This app is close
to
production and I have no test suite, I have fat controllers, skinny
models,
the development.log reaks of depreciation notices, and don’t even ask me
if
its restful. I maintain a bug tracker for the app and I am currently
fixing
minor bugs and still implementing new features. I can break down the
refactoring process into small pieces and still do bug fixes and feature
implementations, it will just take me a while to clean up the code (one
guy
remember). My question is this, does anyone have experience or know of
a
good read about writing tests for an existing app?
Here are the stats for the app so you can get an idea of the size of it.
±---------------------±------±------±--------±--------±----±------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
±---------------------±------±------±--------±--------±----±------+
| Controllers | 4786 | 4392 | 30 | 213 | 7 | 18 |
| Helpers | 198 | 151 | 0 | 11 | 0 | 11 |
| Models | 528 | 480 | 36 | 28 | 0 | 15 |
| Libraries | 164 | 92 | 3 | 7 | 2 | 11 |
| Components | 0 | 0 | 0 | 0 | 0 | 0 |
| Integration tests | 0 | 0 | 0 | 0 | 0 | 0 |
| Functional tests | 2382 | 1706 | 62 | 275 | 4 | 4 |
| Unit tests | 400 | 280 | 40 | 40 | 1 | 5 |
±---------------------±------±------±--------±--------±----±------+
| Total | 8458 | 7101 | 171 | 574 | 3 | 10 |
±---------------------±------±------±--------±--------±----±------+
Code LOC: 5115 Test LOC: 1986 Code to Test Ratio: 1:0.4