Test exception raising in controller

610 views Asked by At

I have a simple controller action which is used for checking that the app is running.

def check(id=1)
  Car.find(id)
  render nothing: true, status: 200
rescue
  render nothing: true, status: 500
end

How do I test the exception. Below is the test for the happy path.

RSpec.describe HealthController do

  describe "GET #check" do
    it "returns 200" do
    expect(response).to have_http_status(200)
  end
end
0

There are 0 answers