[英]How to run rspec with an older version of rspec-core
When I run rspec, I get this error message 当我运行rspec时,出现此错误消息
/Users/umezo/.rvm/gems/ruby-2.1.1@itsonme/gems/bundler-1.6.1/lib/bundler/runtime.rb:34:in `block in setup': You have already activated rspec-core 2.14.8, but your Gemfile requires rspec-core 2.13.1. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
I do in fact specify rspec-core 2.13.1 in my gemfile... 我实际上确实在我的gemfile中指定了rspec-core 2.13.1 ...
gem "rspec-rails", "~> 2.13.0"
and I do have multiple versions of rspec and rspec core, as gem list rspec
returns... 我确实有多个版本的rspec和rspec核心,因为
gem list rspec
返回...
*** LOCAL GEMS ***
guard-rspec (4.2.8, 3.1.0, 1.2.1)
rspec (2.14.1, 2.13.0, 2.5.0)
rspec-core (2.14.8, 2.13.1)
rspec-expectations (2.14.5, 2.13.0, 2.5.0)
rspec-mocks (2.14.6, 2.13.0, 2.5.0)
rspec-rails (2.14.2, 2.13.0, 2.5.0)
I understand that three ways of solving this problem are: 1) prepending bundle exec
to the command; 我了解解决此问题的三种方法是:1)将
bundle exec
放在命令之前; 2) upgrading the rspec in the Gemfile to 2.14.8; 2)将Gemfile中的rspec升级到2.14.8; or 3) removing rspec/rspec-core 2.14.1/8.
或3)删除rspec / rspec-core 2.14.1 / 8。
However, I would like to know how I can run rspec 2.13.0 by default, without removing rspec 2.14.1 . 但是,我想知道如何在不删除rspec 2.14.1的情况下默认运行rspec 2.13.0 。 I know this is possible, as I am able to do this on my other OSX machine, which also has the same two versions of rspec, and the same version of rspec specified in the gemfile.
我知道这是可能的,因为我可以在另一台OSX计算机上执行此操作,该计算机也具有相同的两个版本的rspec,以及在gemfile中指定的相同的rspec版本。 Is there a specific configuration file that bundler/rails/rspec looks at to determine which version of rspec to run?
bundler / rails / rspec是否查看特定的配置文件以确定要运行的rspec版本?
EDIT: Here's more of my config. 编辑:这是我的更多配置。
System OSX Mavericks
Ruby 2.1.1p76
rvm 1.25.31
Bundler 1.6.1
Rails 4.1.0
Found this when looking at the rspec executable generated by RubyGems: 在查看由RubyGems生成的rspec可执行文件时发现了这一点:
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
version = $1
ARGV.shift
end
end
gem 'rspec-core', version
load Gem.bin_path('rspec-core', 'rspec', version)
Which means we can do something like this: 这意味着我们可以做这样的事情:
rspec _2.99.2_ ./spec/workers/base_worker_spec.rb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.