簡體   English   中英

無法再運行rspec

[英]Cannot run rspec anymore

我使用rspec 3.0的ruby 2.0。 我卸載了所有rspec 3.0 gem,並將其替換為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重新gem install rspec ,這給了我rspec 3.0並修復了所有問題。 但是,我再次收到棄用警告。

請告訴我為什么會發生錯誤。 教程作者說,它應與rspec 2.10.0或更高版本一起使用。

教程作者說,它應與rspec 2.10.0或更高版本一起使用。

作者的意思可能是2.x或更高,在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如何處理其版本號感到好奇,請訪問語義版本控制的鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM