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

Mark Wilden mark at mwilden.com
Tue Nov 4 17:58:41 EST 2008

On Tue, Nov 4, 2008 at 2:45 PM, Greg Hauptmann <
greg.hauptmann.ruby at gmail.com> wrote:

> I have an issue in that I have some reference data my migrations run
> in. However when running  "rake spec" it seems to remove the data in
> the test database up front.
> What do you recommend to workaround this issue?

Don't do that. :) At least, that's my opinion. Depending on database
contents for testing is a brittle road to hoe. As I just finished saying, I
like my test database to be clean and identical in schema to my development
database. 'rake spec' does that.

Without knowing your situation exactly, I would suggest either mocking out
calls that you expect to deliver the prepopulated data, creating that data
in your specs as needed, writing fixtures that load the data in, and/or
examining whether that data is really necessary for testing.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081104/568853e6/attachment.html>

More information about the rspec-users mailing list