Why use DatabaseCleaner with rSpec?

Hi list,

I’ve used DatabaseCleaner in the past, but only when using Cucumber
and Selenium (or Steak + Celerity) since turning on
transactional_fixtures would prevent the data being accessible from
app-server that is also triggered for the tests. This works fine, and
is a de-facto solution for this problem.

I don’t see why I would want to use DatabaseCleaner with rspec though,
since everything is in the same process, transactional_fixtures could
do fine, in theory. Or not?

Marcelo.

On 2/8/11 10:49 AM, Marcelo de Moraes S. wrote:

do fine, in theory. Or not?

Marcelo.

If you are using RSpec with Rails and have a single ActiveRecord
connection for your app then you do not need to use DatabaseCleaner and
the built in transactional_fixtures method will do just great. Once you
need to either
a) use a non-AR DB (e.g. mongodb, couchdb)
b) have an out of process testing scenario (e.g. selenium)
c) clean multiple connections (with an ActiveRecord DB or otherwise)
or
d) are not testing a Rails app (where the transactional_fixtures come
from)
then using DatabaseCleaner will make your life easier.

HTH,
Ben

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs