当我运行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>'
知道为什么吗?在这里你得到了我的宝石文件:
宝石文件
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
类似的问题将我带到了这里,除了 rspec-core
之外,我的test
组中的任何 gem 都没有安装,因为显然捆绑器会记住您的初始开关。
将.bundle/config
更新为不包含BUNDLE_WITHOUT: "test"
bundle install
添加正确的宝石。
rspec-core
是rspec-rails
的运行时依赖项,因此您不需要将其显式添加到 Gemfile 中。 您是否由于尝试调试而添加了它?请参阅此处的文档。
当您运行 bundle install
时,bundler 将出去检索必要的依赖项,并将其包含在您的 Gemfile.lock 中,以及支持 Gemfile gem 所需的特定版本。
我建议您首先从Gemfile
中删除rspec-core
并运行bundle install
。 然后看看你的Gemfile.lock
. rspec-core在那里吗?应该是。如果没有,如果您粘贴包含rspec-rails
及其依赖项的锁定文件的代码段会有所帮助?