2

I've got this issue with database locking when I'm testing some threading features I've got in my application--the database locks on one thread and then all the other threads deadlock on that. As there's no explicit transaction in my code I can't just guard and release manually.

I read somewhere that fixtures in TestCase leverage implicit (implicit to MY code) transactions to clean out the database between tests, but I can't find anywhere if this is true for Factory Girl as well.

Does anyone know if it is true and if so, is there a way to turn it off for specific tests, but not all of the tests?

thanks in advance!

jaydel
  • 14,389
  • 14
  • 62
  • 98

1 Answers1

2

FactoryGirl just takes your model, sets the attributes, and calls #save on that model. I think you just need to change a setting. With RSpec, you should have a line in your spec_helper.rb file:

    config.use_transactional_fixtures = true

This config is sent to the Rails testing config. This is then used in the #setup_fixtures method.

The documentation on Rails transactional fixtures

HTH

Eric C
  • 3,886
  • 3
  • 30
  • 26
monocle
  • 5,866
  • 2
  • 26
  • 22
  • Perfect, thanks! I wasn't sure if the configuration for this would be the same for Factory Girl...I owe you a beer. – jaydel Jun 23 '11 at 13:23
  • You led me down this path to get it for individual tests...http://stackoverflow.com/questions/3907815/rails-3-and-rspec-2-turn-off-transactional-fixtures-for-individual-tests – jaydel Jun 23 '11 at 13:24