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.
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
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
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
Restart spring - sometimes it fails to reload after running bundle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With