Ruby on Rails comes with very nice testing tools. Use them!
In order to get your test working follow the next steps:
- First create and set up your testing database, remember that by default you are working under a development environmet so.. if you dont want to lose this configuration, and still test on the same computer you are developing just specify that you will run db:create rake task for test env just like this:
$ rake db:create RAILS_ENV=test
- After your database is created run all migrations using the same “hack”:
$ rake db:migrate RAILS_ENV=test
There are better ways to this, remember this is just a spank on your but to get you started.
For more information refer to this guide by clicking here, there you will find all you need to test like a pro.
I sugest you use the autotest gem to make it easier for you to test, specially on code refactorings.
Install auto test by running:
$ gem install ZenTest
Use it by running:
$ autotest - -rails