Error after upgrading Rails to 6.1: uninitialized constant RSpec::Rails::Railtie::SourceAnnotationExtractor

Viewed 1081

Running rspec after upgrading Rails results in an uninitialized constant error: RSpec::Rails::Railtie::SourceAnnotationExtractor.

The backtrace points to the "rails_helper.rb" file.

I already attempted a bundle update rspec-rails.

1 Answers

I'm adding this question and answer because I didn't find the exact issue or solution when searching StackOverflow.

It turns out that rspec-rails was stuck because rspec wasn't updating (stuck on v 3.6).

The fix:

bundle update rspec rspec-rails

It was critical to update both gems at once. That finally updated rspec-rails to 5.0.1 and rspec to 3.10.0.

Thanks to this thread for vital information: https://github.com/rspec/rspec-rails/issues/1298

Related