我正在学习 Michael Hartl(2011 年)的“Ruby on Rails 3 教程:通过示例学习 Rails”,但遇到了与 rspec 的冲突。现在,当我尝试运行 rspec 时,我得到:
rspec spec/
/home/bill44077/.rvm/gems/ruby-1.9.2-p136@global/gems/bundler-1.0.7/lib/bundler/runtime.rb:27:in `block in setup': You have already activated rspec-core 2.5.1, but your Gemfile requires rspec-core 2.4.0. Consider using bundle exec. (Gem::LoadError)
我查看了我的 Gemfile,没有看到 rspec 的修订要求。我试过了
gem uninstall rspec-rails
bundle install
但这似乎没有帮助。如果我跑
bundle exec rspec spec/
这很好,但我真的想像以前一样运行自动测试,所以我需要让 rspec 像以前一样再次工作。
有什么想法可以解决这个版本问题吗?
谢谢!! 账单
最佳答案
这是因为即使您没有在您的 gemfile 中指定 rspec 的版本,在您的 Gemfile.lock 中它也会存储该版本(在这种情况下看起来像 2.4.0)。
然后,当您运行命令 rspec
时,它会尝试使用比锁定版本更新的版本。运行 bundle update rspec
将更新 Gemfile.lock 中的“锁定”版本,如您所见,它将全部解决。
关于ruby-on-rails-3 - Rails 3 - rspec 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5064606/