I think you best option is to test it how you use them. Also I am sure you made other mistakes that you can refactor, and that is always a great point to add test coverage too. Find that model that got too big or shouldn't exist and work your way from there.
Usually when I am trying to add coverage I find that the code isn't easy to test because it wasn't made with tests in mind. To deal with that, I usually create a layer between what I'm trying to test/refactor, and write a test for the old functionality and then refactor it. How big is your app? 100+ models? Is this app still having new features added? SD Ruby, It's finally time for me to upgrade the first Rails app I ever built. Thanks to all who made some great suggestions previously on approaches for doing so -- I'm well under way. One of the things I want to make right with the upgrade from Rails 2.3 to (initially) 3.1 is adding test coverage. When I started this app over (gulp!) 6 1/2 years ago I was an utter noobie and didn't know jack squat about unit testing or any other kind of software testing. So, the application doesn't have any test coverage. Zero. Zip. Nada. I'm presently bringing all the models into the Rails 3 version of the app, checking gem and plugin dependencies, fixing fully deprecated method calls (I'm looking at you, "named_scope"!) and really just trying to get the app to start cleanly on the Rails console. I've decided I want to use RSpec to write all the tests and am enjoying getting up to speed on that test framework. The question I'm posing to the group is this: what's a good approach to adding tests to existing Rails models using RSpec? What should I be trying to cover? Are there any tests that are particularly smart to run in a framework upgrade situation? What types of tests would you add right off the bat? For now I'm only concerned about the models. As I get more comfortable with the test coverage on them I'll begin bringing over the controllers and views. If you have any advice on an approach I might consider at this point I'd love to get some input. It's never too late to add tests to an app, and I'd like to maximize the bang for the buck here. Cheers, Chris -- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out. -- -- SD Ruby mailing list [email protected] http://groups.google.com/group/sdruby --- You received this message because you are subscribed to the Google Groups "SD Ruby" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
