2015-03-30 41 views
1

我試圖將項目從RSpec的2升級到RSpec的3,但它與下面的錯誤而失敗:爲什麼rspec 3出現錯誤:僅支持`receive_messages`匹配器?

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> 

這裏是行:

expect(last_response.ok?).to be true 

This post suggests一個只有

不需要
require 'rspec/expectations' 
include RSpec::Matchers 

但是,我已經做到了這一點,它仍然報告錯誤。 This user也似乎遇到此問題,但尚未能夠引出解決方案截至2015年3月30日。

我使用rspec Sinatra並且不使用黃瓜或菠菜。

任何人都可以解釋如何解決RSpec 3中的這個錯誤?謝謝。

+0

你確定你所提到的行實際上是給這個錯誤嗎? – 2015-04-01 07:32:10

回答

2

我已通過使用extend而不是includeRSpec::Matchers更正了此問題。在調試這個並試圖整合pry時,我提出了改變。

因此,我的代碼現在看起來像:

extend RSpec::Matchers 

而且不

include RSpec::Matchers