I have a method to update people\'s attribute, and it will rescue ActiveRecord::RecordNotFound
if the people cannot be found. The method is:
def u
you can try :
let!(:error_failed) { { error: 'Failed' } }
context 'when people is not found by params' do
it 'return 404 and render json failed'
null_object = double.as_null_object
allow(People).to receive(:find).with(params[:id]).and_raise(ActiveRecord::RecordNotFound.new(null_object)
put :update, format: :json, .....
expect(response.body).to error_dailed.to_json
expect(response.status).to .....
end
end