I'm developing a rails application that functions as a directory/phonebook application for a small organization.
Background
The application basically consolidates information from multiple internal Web APIs and stores them in the local SQLite3 DB. The application is basically a glorified front-end that reads directly from this DB.
Every X hours, a rake task is scheduled that pulls information from the Web APIs into the DB. On the first run, the DB is obviously blank but on subsequent runs it's updating existing data and creating any new records if necessary. All the logic to query the api's and insert into the DB is in lib/update.rb
Question
How should I go about setting up tests for the above workflow? I know rails has very nice support for fixtures. But in this case I don't want to set up pre-configured data as a fixture. I want to mock Web API calls and run it through lib/update.rb
to ensure that it is getting correctly inserted with the right logic. I also want to do several runs to mock the first run and subsequent runs and assert the correct behavior. Should I be putting everything in /test/unit/update_test.rb
as a unit test?
Also how do I manage data between Unit tests and Model Tests? I will definitely be using fixtures for Models, so should I clear the DB after running Unit tests?
Thanks!
Aucun commentaire:
Enregistrer un commentaire