rails-rspec error cannot load such file -- rspec/core/formatters/progress_formatter

Viewed 25098

I've broken my rails-rspec. I switched to a different gemset to run a 3rd party test. When I returned to my 2.3.0(default) gemset, I had the following errors.

running rspec gets:

/.rvm/gems/ruby-2.3.0/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require': cannot load such file -- rspec/core/formatters/progress_formatter (LoadError)

running rails generate rspec:install returns:

Could not find generator 'rspec:install'. Maybe you meant 'devise:install' or ...

I have tried uninstalling and reinstalling, but errors persist.

Running rspec -v returns:

- rspec-core 3.6.0
- rspec-expectations 3.6.0
- rspec-mocks 3.6.0
- rspec-rails 3.6.1
- rspec-support 3.6.0

It seems that ruby cannot find rspec-core. I have tried the workaround from this post without success. Thank you in advance for any insight you might provide.

Running

rails 4.2.0, ruby 2.3.0

7 Answers

Running bundle exec rspec solved it for me.

Running bundle clean --force did the trick for me, turns out there's some outdated gem in my system

I learned this from Victor Hazbun - expert on CodeMentor and Egghead.io:

Run gem list | grep rspec and pay attention to any gems that list multiple versions.

Then run gem uninstall ______ for each of those versions (removing ALL of the versions of each).

Then run bundle afterward. This will sync your versions with the versions in your gemfile.

I was getting the error below in a rails app and none of the solutions here worked for me.

gems/rspec-core-3.8.0/lib/rspec/core/formatters.rb:210:in `require': cannot load such file -- rspec/core/formatters/progress_formatter (LoadError)

Emptying the gemset and re-installing did.

This assumes you are using rvm and a .ruby-gemset at the root of your app.

$ rvm gemset empty <name-of-gemset>
$ bundle install

I was trying to make a contribution to CocoaPods and was getting the same error when I was doing rspec foo_spec.rb. Turns out they were NOT using rpsec at all. They seem to have had a special test runner:

CocoaPods uses bacon as a test runner. To run all tests, use bundle exec rake spec in the root of the project. If you want to run a specific test instead, use bundle exec bacon spec/[folder]/[name]_spec.rb

For more on that see here

If you run the specs from RubyMine, you can specific the RSpec version in Run Configuration.

Configuration Modifications

Related