[rspec-users] how to avoid tests removing data that my migrations put in?

Pat Maddox pergesu at gmail.com
Tue Nov 4 19:56:13 EST 2008

"Mark Wilden" <mark at mwilden.com> writes:

> On Tue, Nov 4, 2008 at 4:26 PM, Pat Maddox <pergesu at gmail.com> wrote:
>     aslak's right though in that case too.  In your spec_helper, just loop
>     over the tables and delete everything, then insert the seed data you
>     want, and it should be good to go.
> But then Ashley's comment applies: you've got the same facts in two places. Best thing is to
> avoid the dependency, if at all possible.

Sure, but you can encapsulate all that stuff too.  When I've done stuff
like this in the past (and on second thought I have done it just as
aslak suggested, I just didn't think of it :) we've created some seed
data builders.  Then it becomes a simple matter of SeedData.build_data
to kick off the whole deal.


More information about the rspec-users mailing list