rspec-core不是捆绑包的一部分。将其添加到Gemfile

时间:2016-03-09 19:31:30

标签: ruby-on-rails ruby rspec

当我运行rspec spec时,我收到此错误:

bundle exec rspec spec/models/spree_user_spec.rb
/Users/martins/.rvm/gems/ruby-2.2.3@solidus/gems/bundler-1.11.2/lib/bundler/rubygems_integration.rb:304:in `block in replace_gem': rspec-core is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
        from /Users/martins/.rvm/gems/ruby-2.2.3@solidus/bin/rspec:22:in `<main>'
        from /Users/martins/.rvm/gems/ruby-2.2.3@solidus/bin/ruby_executable_hooks:15:in `eval'
        from /Users/martins/.rvm/gems/ruby-2.2.3@solidus/bin/ruby_executable_hooks:15:in `<main>'

知道为什么吗?在这里你得到了我的Gemfile:

的Gemfile

source 'https://rubygems.org'

ruby '2.2.3'

gem 'solidus'

gem 'quiet_assets', group: :development

gem 'dotenv-rails', groups: [:development, :test]

gem 'puma'

gem 'cancancan', '~> 1.10'

group :test do
  gem 'factory_girl_rails', '~> 4.5.0'
  gem 'capybara', '~> 2.4'
  gem 'capybara-screenshot'
  gem 'database_cleaner', '~> 1.3'
  gem 'email_spec'
  gem 'launchy'
  gem 'rspec-activemodel-mocks', '~>1.0.2'
  gem 'rspec-collection_matchers'
  gem 'rspec-its'
  gem 'rspec-core'
  gem 'rspec-rails', '~> 3.3.0'
  gem 'simplecov'
  gem 'webmock', '1.8.11'
  gem 'poltergeist'
  gem 'timecop'
  gem 'with_model'
  gem 'rspec_junit_formatter'
end

gem 'rails', '4.2.5'
gem 'pg', '~> 0.15'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'

gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc




group :development, :test do
  gem 'byebug'
end

group :development do
  gem 'web-console', '~> 2.0'

  gem 'spring'
end

group :development, :test do
  gem 'rubocop'
  gem 'spring-commands-rspec'
  gem 'guard-rspec', require: false
end

group :darwin, :test do
  gem 'rb-fsevent'
end

group :production do
  gem 'exception_notification'
  gem 'rails_12factor'
end

2 个答案:

答案 0 :(得分:0)

rspec-corerspec-rails的运行时依赖项,因此您不需要将其显式添加到Gemfile中。您是否因为尝试调试而添加了它?请参阅文档here

当你运行bundle install时,bundler会出去检索必要的依赖项并将它们包含在你的Gemfile.lock中,并提供支持你的Gemfile gems所需的特定版本。

我建议您首先从rspec-core移除Gemfile并运行bundle install。然后看看你的Gemfile.lock。那里有rspec核心吗?它应该是。如果没有,那么粘贴包含rspec-rails及其依赖项的锁定文件的片段会有所帮助吗?

答案 1 :(得分:0)

类似的问题导致我在这里,除了rspec-core之外,我的test组中没有安装任何宝石,因为显然捆绑器会记住您的初始开关。

更新.bundle/config以不包括BUNDLE_WITHOUT: "test"bundle install添加正确的宝石。