简体   繁体   中英

Could not find generator 'rspec:install'

I am not able to run the command rails generate rspec:install in my terminal. it give me the following error:

Could not find generator 'rspec:install'. Maybe you meant 'jquery:install' or 'devise:install' or 'responders:install'
Run `rails generate --help` for more options.

Here is the gem in my Gemfile:

group :development, :test do
  gem 'pry'
  gem 'pry-remote'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'

  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'

  # allow CORS for fonts, etc. for local dev
  gem 'rack-cors'

  gem 'capybara'
  gem 'rspec-rails', '~> 3.0.1'
end

I have seen people suggest to put the following line of code in application.rb but I have tried this and it doesn't work:

config.generators do |g|
  g.test_framework  :rspec
end

I have done gem install rspec-rails and bundle install but I still cannot run rails generate rspec:install

Any more suggestions?

I had the same problem with rails 6.0.3 and ruby 2.7.1.

I tried adding rspec-rails gem in the :development, :test group and out of the group. I tried spring stop and bundle exec generate rspec:install , neither worked.

And I confirm that adding rspec gem to Gemfile (in my case in :development, :test group) solved my problem.

in your gem file add

gem 'rspec'

it cleared my problem,.. hope it will help u too..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM