Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么rspec 3失败并出现错误:仅支持“接收消息”匹配器?_Rspec_Rspec2_Rspec3 - Fatal编程技术网

为什么rspec 3失败并出现错误:仅支持“接收消息”匹配器?

为什么rspec 3失败并出现错误:仅支持“接收消息”匹配器?,rspec,rspec2,rspec3,Rspec,Rspec2,Rspec3,我正在尝试将项目从RSpec 2升级到RSpec 3,但失败,出现以下错误: Failure/Error: Unable to find matching line from backtrace only the `receive` or `receive_messages` matchers are supported with `expect(...).to`, but you have provided: #<RSpec::Matchers::BuiltIn::Equal:0

我正在尝试将项目从RSpec 2升级到RSpec 3,但失败,出现以下错误:

 Failure/Error: Unable to find matching line from backtrace
   only the `receive` or `receive_messages` matchers are supported with `expect(...).to`, but you have provided: #<RSpec::Matchers::BuiltIn::Equal:0x007f99a974a230>
只需

require 'rspec/expectations'
include RSpec::Matchers
但是,我已经这样做了,它仍然报告错误。似乎也遇到了这一问题,但截至2015年3月30日,尚未找到解决方案

我使用rspec,不使用黄瓜或菠菜


有人能解释一下如何在RSpec 3中解决这个错误吗?谢谢。

对于
RSpec::Matchers
,我已使用
extend
而不是
include
纠正了此问题。在调试和尝试集成时,我建议进行更改

因此,我的代码现在看起来像:

extend RSpec::Matchers
而不是

include RSpec::Matchers

你确定你提到的那一行实际上给出了错误吗?
include RSpec::Matchers