David Kahn wrote: > They should not be far from your mind! You should set them up in every > test and scenario for which you need them, so that you know exactly > which features depend on them. > > So take the time now to drop the bad practice and do it right! [Still not quoting properly. That was me.]
> > I see the point and trying to swallow it. That's going to make me think > a > bit differently but I can see the benefit. Although, this also makes me > think that doing associations or the like within factories according to > your > logic would also be bad practice, right? No. Part of the reason we use factories is so we can produce, on the fly, a usable record with all associations and validations satisfied. > I mean, that is also data which > is > implied. Huh? You mean in the sense that you didn't explicitly create the associated records? That's OK, because you're still creating them *for the particular test*. See, your test DB should start out every scenario or test completely empty, and only create the records needed for that particular test. If (say) Factory :event also creates a User record for the Event to belong to, that's fine -- an Event (in this example) can't exist without an owning User, so we need the User in order to test the Event. We are creating all necessary records, but only the necessary records. Best, -- Marnen Laibow-Koser http://www.marnen.org [email protected] -- 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 [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.

