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!

1 Answer 1

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

2
  • Perfect, thanks! I wasn't sure if the configuration for this would be the same for Factory Girl...I owe you a beer.
    – user483040
    Jun 23, 2011 at 13:23
  • You led me down this path to get it for individual tests...stackoverflow.com/questions/3907815/…
    – user483040
    Jun 23, 2011 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.