alpaca
alpaca

Reputation: 1231

RSpec tests failing with undefined method `respond_with'

I'm working on a Rails API Tutorial and facing an error. Whenever I run my tests, I get

  1) Api::V1::UsersController PUT/PATCH #update when is not created
     Failure/Error: it { should respond_with 422 }

     NoMethodError:
       undefined method `respond_with' for #<RSpec::ExampleGroups::ApiV1UsersController::PUTPATCH
Update::WhenIsNotCreated:0x007f860e070eb8>
       Did you mean?  respond_to

I found two other posts (this and this) that are pointing to a very similar problem, but both of them are not solved. Does anyone have a solution to this? Thanks!

Upvotes: 2

Views: 565

Answers (1)

Jagdeep Singh
Jagdeep Singh

Reputation: 4920

As mentioned here, instead of:

it { should respond_with 422 }

Try this:

it { expect(response).to have_http_status(422) }

Upvotes: 4

Related Questions