I have a Rails test suite that uses DatabaseCleaner
, FactoryGirl
, and Capybara-Webkit
. All my tests pass on my machine when running the suite, including when running them all in parallel (parallel_rspec
).
When I push to CI (circleci) I always get a failure in my integration tests. I suspect it is because I am using transaction
strategy in my unit tests (controllers, services, views, etc...). Perhaps it is a bad practice, but if I need a model in my controller (for example) I have been doing FactoryGirl.create(:my_model)
. But I suspect every single place I use FactoryGirl to create a model I should also be making that test use a truncation
strategy in DatabaseCleaner.
I just marked my entire suite to use truncation
and pushed to CI and it's green which is great, but now the suite takes 50% longer to run.
So, when instantiating ActiveRecord
models with FactoryGirl
, should I ALWAYS mark those tests to use truncation
?
Thank you for any and all feedback.