2

I am attempting to upgrade a project from RSpec 2 to RSpec 3, but it is failing with the following error:

 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>

Here is the line:

expect(last_response.ok?).to be true

This post suggests one need only

require 'rspec/expectations'
include RSpec::Matchers

However, I have done this and it still reports the error. This user also seemed to encounter this issue but has not been able to elicit a solution as of 3/30/2015.

I am using rspec with Sinatra and do not use cucumber or spinach.

Can anyone explain how to resolve this error in RSpec 3? Thanks.

Community
  • 1
  • 1
esilver
  • 27,713
  • 23
  • 122
  • 168

1 Answers1

4

I have corrected this issue by using extend instead of include for RSpec::Matchers. While debugging this and attempting to integrate pry, I found this post which suggested the change.

Thus, my code now looks like:

extend RSpec::Matchers

And not

include RSpec::Matchers
esilver
  • 27,713
  • 23
  • 122
  • 168