[rspec-users] Keeping unit tests from hitting the DB

Ben Mabey ben at benmabey.com
Thu Aug 23 12:41:55 EDT 2007

Hey all,
I think I saw a thread about this earlier (maybe it was on the devlopers 
list) but I am wondering if anyone has stubbed out AR so that the unit 
test do not hit the database.  The reason I am curious is because there 
was a lightning talk given at the Ruby Hoedown (watch it here: 
http://rubyhoedown2007.confreaks.com/session06.html) about separating 
unit tests from the DB entirely and making it a lot faster.  I'm not 
just talking about not using fixtures but this would not even query the 
DB for columns or do any inserts or updates either.  Dan Manges was the 
presenter and he talks about it on his blog and his newly released gem:

I haven't experimented with the gem yet but I'm sure it could be changed 
to work with rspec.  I'm curious about people's opinions about this 
practice and see if anyone has done something similar with rspec 
already.   I think the speed is very attractive but if you were to do 
this you would need to to have another type of test that would actually 
hit the DB.  Has anyone done this with rspec that could shed a little 
more light on the advantages/disadvantages?


More information about the rspec-users mailing list