[rspec-users] Setting use_transactional_fixtures=false for a single spec - a bad idea?

Peter Marklund peter_marklund at fastmail.fm
Fri Aug 31 11:13:06 EDT 2007


Hi!
I would really like to find a way to allow me to write RSpec  
specifications for code that use database transactions. I know I can set

config.use_transactional_fixtures = false

in my spec_helper.rb. That works, and that's great, but it will (I  
think) slow down my specs quite a bit. I would like to turn off  
transactional fixtures for just a single spec (describe), or even  
better, just a single example (it). I tried this:

   before(:all) do
     Spec::Runner.configure do |config|
       config.use_transactional_fixtures = false
     end
   end

   after(:all) do
     Spec::Runner.configure do |config|
       config.use_transactional_fixtures = true
     end
   end

but that didn't work.

Or is setting use_transactional_fixtures=false on a global level  
really the way to go even if it slows you down? It certainly feels a  
lot cleaner and solid to me. Maybe I need more db stubbing.

Thanks in advance for any pointers!

Cheers

Peter
http://marklunds.com



More information about the rspec-users mailing list