[rspec-users] stale records with integration testing?

Patrick J. Collins patrick at collinatorstudios.com
Tue Feb 14 02:36:32 EST 2012

> > 2.) DatabaseCleaner:
> >
> > RSpec.configure do |config|
> >  config.before { DatabaseCleaner.start }
> >  config.after { DatabaseCleaner.clean }
> > end
> >
> > Look into what those do. Let us know if you get stuck.
> What Justin says is true if you're running in the same process. If
> you're using Capybara to run examples in-browser, then option 2 will
> work for you, but option 1 will not.

Hmmm..  Well, I had actually tried the DatabaseCleaner gem prior to
asking my question, and I saw no difference in the results...  I just
put that code back in spec_helper, and ran my specs and they fail again
with "email already taken".  It seems to break unless I explicitly put:

User.all.map(&:destroy) in a before block........

Is there any reason why DatabaseCleaner might not be working?  I'm on
Rails 3.2 with rspec 2.8.0, and database_cleaner 0.7.1

Patrick J. Collins

More information about the rspec-users mailing list