ruby - Rspec 无方法错误

标签 ruby rspec

我下载了 rspec 和 bundler 。我遵循非常具体的指示,但我不断收到这些错误消息。它说它应该运行。

我有 rspec-core 版本 2.99,但也有版本 3.2。我已将 2.99 版本放入此 rspec 文件中,但似乎没有帮助。

Qureshis-MacBook-Pro:test-first-ruby-master Qureshi$ bundle exec rspec spec/00_hello_spec.rb
/Users/Qureshi/Desktop/test-first-ruby-master/spec/spec_helper.rb:31:in `block (2 levels) in <top (required)>': undefined method `include_chain_clauses_in_custom_matcher_descriptions=' for #<RSpec::Expectations::Configuration:0x007fcf3289f4c8> (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:580:in `expect_with'
from /Users/Qureshi/Desktop/test-first-ruby-master/spec/spec_helper.rb:23:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core.rb:154:in `configure'
from /Users/Qureshi/Desktop/test-first-ruby-master/spec/spec_helper.rb:19:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `block in setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `each'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration_options.rb:25:in `configure'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/command_line.rb:17:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:103:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:17:in `block in autorun'

Qureshis-MacBook-Pro:test-first-ruby-master Qureshi$ bundle exec rspec spec
/Users/Qureshi/Desktop/test-first-ruby-master/spec/spec_helper.rb:31:in `block (2 levels) in <top (required)>': undefined method `include_chain_clauses_in_custom_matcher_descriptions=' for #<RSpec::Expectations::Configuration:0x007ff5c190f560> (NoMethodError)
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:580:in `expect_with'
from /Users/Qureshi/Desktop/test-first-ruby-master/spec/spec_helper.rb:23:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core.rb:154:in `configure'
from /Users/Qureshi/Desktop/test-first-ruby-master/spec/spec_helper.rb:19:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `block in setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `each'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration.rb:1036:in `setup_load_path_and_require'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/configuration_options.rb:25:in `configure'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/command_line.rb:17:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:103:in `run'
from /Library/Ruby/Gems/2.0.0/gems/rspec-core-2.99.1/lib/rspec/core/runner.rb:17:in `block in autorun'

最佳答案

您尝试在 spec_helper.rb 文件 (include_chain_clauses_in_custom_matcher_descriptions) 中设置的配置选项是在 RSpec 3.1 中引入的 https://github.com/rspec/rspec-expectations/blob/v3.1.0/Changelog.md ,但您运行的是 RSpec 2.99。

关于ruby - Rspec 无方法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28663952/

相关文章:

ruby - 为什么 a << b 的行为与 a = a + b 不同(使用带字符串的复制哈希数组)

java - AES PBE 在 Java 中加密/在 Ruby 中解密

testing - Rails 路由和 rspec 测试错误

ruby-on-rails - rake 分贝 :test:prepare in Rails 3 app fails with file not found

ruby-on-rails - rspec-core 不是 bundle 的一部分。将其添加到 Gemfile

mysql - 主动记录查询以从三个关联模型中获取数据

ruby - Psych to_yaml 选项的文档?

ruby-on-rails - Rails 3 和 PDFKit,如何将 HTML 文件转换为横向 PDF?

ruby-on-rails-3 - Rails 3 Rspec 测试数据库持续存在

rspec集成/请求规范与 Controller 规范,重点是JSON API