ruby – 不能再运行rspec了
作者:互联网
我用rspec 3.0获得了ruby 2.0.我卸载了所有的rspec 3.0宝石,并用2.0替换它们.我这样做是为了摆脱弃用警告.现在,我的规格不起作用.我收到以下错误.错误告诉我什么以及如何解决?没有任何堆栈溢出帖子对此有帮助.
/zombie/spec/spec_helper.rb:29:in `block (2 levels) in <top (required)>': undefined method `include_chain_clauses_in_custom_matcher_descriptions=' for #<RSpec::Matchers::Configuration:0x00000001a73928> (NoMethodError)
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:398:in `expect_with'
from /home/lsusr/Code/Rspec/zombie/spec/spec_helper.rb:21:in `block in <top (required)>'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core.rb:92:in `configure'
from /home/lsusr/Code/Rspec/zombie/spec/spec_helper.rb:17:in `<top (required)>'
from /home/lsusr/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/lsusr/.rvm/rubies/ruby-2.0.0-p598/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:434:in `block in requires='
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:434:in `map'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:434:in `requires='
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:20:in `block in configure'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:19:in `each'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/configuration_options.rb:19:in `configure'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:21:in `run'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
from /home/lsusr/.rvm/gems/ruby-2.0.0-p598/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'
好的,我找到了解决办法.
我刚刚删除了所有不必要的宝石
for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
然后,我刚刚使用gem install rspec重新安装rspec,它给了我rspec 3.0并解决了所有问题.但是,我再次收到了弃用警告.
请告诉我发生错误的原因.教程作者说它应该与rspec 2.10.0或更高版本一起使用.
解决方法:
The tutorial author said that it should work with rspec 2.10.0 or higher.
可能作者的意思是2.10或更高,在2.x范围内. RSpec 3.x有重大变化.
尝试像以前一样卸载gem,然后:
gem install rspec '>=2.10', '<3'
然后运行你的代码.
使用RSpec 3时发生的弃用警告并不错;他们正在指导你告诉你,你正在调用的RSpec方法将被逐步淘汰.移动整个版本号时,这些类型的警告是典型和精细的,例如2.x到3.x.
使用RSpec 2.0时出现的错误是因为这是一个非常旧的版本,并且您调用的方法在2.0中不存在.这可能是教程作者说使用2.10或更高版本的原因.
很可能该教程已经过时,因此最好的解决方案是编写教程作者并让他/她知道更新它.
如果您对RSpec的版本号如何感到好奇,这里有一个链接到Semantic Versioning.
标签:linux,ruby,rspec 来源: https://codeday.me/bug/20190708/1402400.html