Constantin Gavrilescu wrote:
> I have three questions:
> 1. I don't want to run this MinimumData.populate task before each
> scenario because it takes 8 seconds. Should I make it run just once,
> globally?

Don't use seed data for running tests. I would highly recommend using a 
Factory framework instead. Factories allow you to create only the data 
actually used by individual tests. In many cases factory objects can be 
use in memory only and never have to touch the database. Also mocking 
can be used to greatly reduce the overhead you're seeing with your seed 
data generation technique.

http://github.com/notahat/machinist
http://github.com/thoughtbot/factory_girl

> 2. Do I have to cleanup the database with an After.do? I really don't
> want to do that, because I will duplicate the logic in the After.do,
> only with Model.delete_all statements. I noticed that after my first
> run, the test db has all that data still in. I can purge it with rake
> db:test:purge and the reinitialize it. Is that a good practice?

The test database should be reset after every test. You don't want to 
have to deal with side-effects that cross test cases. This is why 
fixture data, or even better, Factory frameworks exist.

> 3. Have you got any other comments or advice by looking at the code?

Part of the reason your data generation takes so long is that you're 
probably doing it all with Ruby and ActiveRecord. This it completely 
fine for a one-time population of seed data. Actually Rails provides a 
standard way to do that. See rake db:seed for more details on this, in 
case you were unaware.
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to