The error occurred while evaluating nil.[]= in Integration Tests

If you’re receiving HTTP 500 errors during your integration tests on Rails, here’s a gotcha. If you’re running version 2.x, dig into your test.log. If you find

Status: 500 Internal Server Error

You’ve come across this lovely bug. The fix is pretty simple luckily enough; add the following to your /config/environments/test.rb:

ActionController::RackRequest::DEFAULT_SESSION_OPTIONS[:database_manager] = CGI::Session::ActiveRecordStore

You should now be able to integration test to your heart’s content.