Add to your Gemfile:
group :development, :test do
gem 'rspec-rails'
end
and run bundle install
make sure that it is in both the :development and :test blocks. If you inadvertently put it only in the :test block, it will give the error above (that’s because by default you’re running in the development
environment and rspec ins’t available to that environment).
rails generate rspec:install
should then run as expected.