Working with RSpec & Capybara, I\'m getting an interesting test failure mode which goes away with a few subtle rearrangements of lines in the test case...stuff that shouldn\
With the help of the Factory Girl mailing list I've found the issue.
By default RSpec uses transactions to maintain the database in a clean state and each transaction is tied to a thread. Somewhere along the pipeline the visit_page command splits off and the transaction tied to the current thread dies.
The solution is simple: disable transactions.
describe "Sessions" do
self.use_transactional_fixtures = false
it 'no longer uses transactions' do
#whatever you want
end
end
Update for Rails 5.1
As of Rails 5.1, use_transactional_fixtures
is deprecated and should be replaced with use_transactional_tests
.
self.use_transactional_tests = false