I recently upgraded to Rails 5.1 from v4.3 and am now getting this error when running tests:
An error occurred while loading ./spec/controllers/admin/capac
Try setting config.eager_load = true in your environment file. This will load all files in memory during boot & will point out existing syntax errors in first place if any.
config.eager_load = true