Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find generator rspec:install (q2)

Tags:

rspec

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.

like image 902
Simplicity Avatar asked Aug 06 '10 17:08

Simplicity


8 Answers

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.

like image 79
Andreas Avatar answered Nov 17 '22 21:11

Andreas


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

like image 25
Ven Avatar answered Nov 17 '22 22:11

Ven


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.

like image 6
thekingoftruth Avatar answered Nov 17 '22 22:11

thekingoftruth


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.

like image 4
arturvt Avatar answered Nov 17 '22 22:11

arturvt


Remove all rspec versions by running the following commands as suggested by Sydney in another post and then install -V 2.0.1

gem uninstall rspec
gem uninstall rspec-core rspec-expectations rspec-mocks rspec-support
gem install rspec -v 2.0.1

add the following line to the gem file

gem 'rspec-rails', '~> 2.0.0'

and then run

rails generate rspec:install

it runs without any issues

like image 3
erukumk Avatar answered Nov 17 '22 23:11

erukumk


I got this same error and found that i had forgotten to save the Gemfile changes I made in Sublime prior to running the Bundle install command. I saved and then reran the bundle install and was able to run the rails generate rspec:install command

like image 2
johnbelmonte Avatar answered Nov 17 '22 22:11

johnbelmonte


Add gem 'rspec-rails' in Gemfile and save it. Run bundle command in Terminal. And in config/application.rb, add this line of configuration

config.generators do |g|
  g.test_framework   :rspec, :fixture => true, :views => false
  g.integration_tool :rspec, :fixture => true, :views => true
end
like image 2
Amrit Dhungana Avatar answered Nov 17 '22 22:11

Amrit Dhungana


Restart spring - sometimes it fails to reload after running bundle.

like image 2
Alex Wdowinski Avatar answered Nov 17 '22 21:11

Alex Wdowinski