In my Rails project I\'m using rspec-mocks using any_instance but I want to avoid this deprecation message:
Using any_instance from rspec-mocks\' old :should synta
Use allow_any_instance_of:
describe (".create") do it 'returns error when...' do allow_any_instance_of(User).to receive(:save).and_return(false) post :create, user: {name: "foo", surname: "bar"}, format: :json expect(response.status).to eq(422) end end