How to test exception raising in Rails/RSpec? December 29, 2022 by Tarik Use expect{} instead of expect(). Example: it do expect { response }.to raise_error(Errors::CarBrandNotFound) end