I'm trying to move a Rails 3 app that's using Fixtures over to Factory Girl and am not entirely sure on the proper approach to the database. (Note that I'm using Rspec for the tests).
I have a seeds.db
that has data that is needed for my functional and integration tests, but when it comes to, say, the model test for my Role
model, this seeded data might get in the way if I want to make an admin Role from the factory, but there's already an admin role in the database from my seed, and the name column must be unique. Additionally, any data I create in these model tests may interfere with my integration tests as I'll have additional data I'm not expecting.
So a couple questions I guess:
What's the proper way to handle the database in my unit tests? I need the seeded data for the other tests, but they seem to be getting 'in the way' right now. Am I forced to make unique data with sequences, or is there a way load the seed data just for functional and integration tests, etc?
Is there a proper way to clearing out the factory data so that it's just the seed data for the functional and integration tests?
Completely new to Factory Girl right now, and just want to learn it properly instead of hacking my way through it. Thanks for any input.