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 to run redis and sidekiq on background. In my case it was one of reasons.
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.
When i got the same error with similar stacktrace, it helped me to fix a syntax error in factories.
Check that your Test DB is up to date before anything else.
rake db:test:prepare.
Turns out this was caused by test failures higher in the stack trace. It was hard to see what the root cause was because there was so much in the console. If you get this issue, I'd suggest using --fail-fast so you don't get overwhelmed with recurrent error messages. Then check what the first error is.
For me it was a FactoryBot update from version 4
to 5
. I didn't see the deprecation warning because I jumped versions:
DEPRECATION WARNING: Static attributes will be removed in FactoryBot 5.0.