Could not find generator rspec:install (q2)

I'm trying to follow this tutorial here: http://railstutorial.org/chapters/static-pages#top

When I run:

$ rails generate rspec:install

I get:

Could not find generator rspec:install.

What could be the problem?

[Rails 3, 4, 5, 6, 7]

Thanks.


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.


Make sure you install rspec-rails and not only rspec. Sigh, I lost some time.


If you, like me, created a project, decided you wanted to archive the old directory and start again, but left spring running in the background on accident, spring won't reload from the correct directory and you'll be very confused.

The solution is to stop spring and let it restart on its own.


I had do both gem install rspec and then add to gemfile as Andreas said.

using Rails 3.2.1 and ruby 1.9.3 at windows 7 and worked perfectly.