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.
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.
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
I had this exact same error and this solved it.
I changed the version of the rspec-rails gem in the gemfile according to this list that I found in the README section of the gem's github repo:
So, in my case, I upgraded to 6.1, so I used: gem 'rspec-rails', '~> 6.0.0'