Logic inside my class sometimes uses Rollbar.silenced
to ignore some exception (so they don't get reported).
I'm trying to write a test which ensure that rollbar actually report error.
it 'does not mute rollbar' do
expect(Rollbar).not_to receive(:silenced)
expect(Rollbar).to receive(:error).with(any_args).and_call_original
expect { query }.to raise_error(unknown_exception)
end
Unfortunately rollbar doesn't use in :error
, :critical
, :warning
etc. methods when reporting unrescued errors.
I saw report_exception_to_rollbar
and call_with_rollbar
inside rollbar sourcecode which are wrapped with Rollbar.scoped
.
So I tried to test it with:
expect(Rollbar).to receive(:scoped).with(any_args).and_call_original
but it also told me:
Failure/Error: expect(Rollbar).to receive(:scoped).with(any_args).and_call_original
(Rollbar).scoped(*(any args))
expected: 1 time with any arguments
received: 0 times with any arguments
How do I ensure that the exception is caught by rollbar and test it with rspec?