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

Greg Hauptmann greg.hauptmann.ruby at gmail.com
Tue Nov 4 22:25:25 EST 2008


so is the concept to build up all seed data creation in one
place/method, & then for the rake spec case run this in via the "test"
environment.rb file?

But then if you were to use rake:migrate to drop back a couple of
version you might be in a spot of bother? (ie newest seed data not
then tied to migration)?


On 11/5/08, Pat Maddox <pergesu at gmail.com> wrote:
> "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.
>
> Pat
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list