找不到生成器'rspec:install'

时间:2015-03-17 20:16:27

标签: ruby-on-rails rspec integration-testing

我无法在终端中运行命令rails generate rspec:install。它给我以下错误:

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

这是我的Gemfile中的gem:

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

我看到人们建议在application.rb中添加以下代码行,但我已经尝试了这个并且它不起作用:

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

我已完成gem install rspec-railsbundle install,但仍无法运行rails generate rspec:install

还有其他建议吗?

2 个答案:

答案 0 :(得分:1)

我在Rails 6.0.3和ruby 2.7.1上遇到了同样的问题。

我尝试将817个gem添加到rspec-rails组中,并从该组中删除。 我尝试了:development, :testspring stop,但都没有用。

我确认向bundle exec generate rspec:install组中添加rspec宝石到Gemfile中可以解决我的问题。

答案 1 :(得分:0)

在你的gem文件中添加

gem 'rspec'

它解决了我的问题,希望它也能帮到你..