I'm working on a solution that resolves the common "seed data vs.
fixtures" issue.

It comes down to:

def delete_existing_fixtures
    @connection.delete "DELETE FROM
#[email protected]_table_name(table_name)}", 'Fixture Delete'
end

Which deletes all records in a particular table. This is what causes
the "hey, I seeded the database by overriding a rake task yet my unit
tests still kill my database records" issue.

One solution to this would be to change that DELETE statement to
"DELETE...WHERE" and deleting records by id, rather than deleting all
records.

I recognize the importance of needing to re-insert fixture data for
tests (so each test has unadultered fixtures data in the db). So my
question is, are there any major red flags to changing that delete
statement, resulting in fixture records being deleted but seed data to
remain in the database?

Or would it be better to insert seed data right before each time the
fixtures are re-inserted?

One approach is more simple than the other, both in terms of
implementation and the test suite performance.

Thanks for your input.

-- 
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.

Reply via email to