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
Suggestion: try loading the app in development after adding config.eager_load = true
to your development.rb file, which should give you an actually useful error message pinpointing the problem code.
In my case, a Rails 5.2 app, it was purely a result of upgrading from Ruby 2.4.5 to 2.5.8 which pinpointed the sole issue was unmatched range specifier in char-class
in a very long regex that has been working for years.