On 17 January 2012 15:04, Rodrigo Ruiz <[email protected]> wrote: > Hi, I have to test one of my models, but it uses a seed database. > > How do I delete everything on my database and create it again from seed > (default code for some examples) for every one of my unit tests?
I think most nowadays think that factories are the best way of testing, using something like factory_girl. I think the free-to-use-online tutorial railstutorial.org uses factories for testing. That is a good tutorial anyway and well worth working through. If you don't want to use factories you should use fixtures for populating the test database. I think the Rails Guide on testing covers this. Then rails will automatically reset the test database for each test. I would expect any good tutorial on rails to either use factories or fixtures. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

