Sha256: 80283e446612e794f5204fe0a15d62ba9f737e8a8c71af32421e753450aaa762
Contents?: true
Size: 942 Bytes
Versions: 19
Compression:
Stored size: 942 Bytes
Contents
require 'spec_helper' require 'active_support/rescuable' require 'rollbar/active_job' describe Rollbar::ActiveJob do class TestJob # To mix in rescue_from include ActiveSupport::Rescuable include Rollbar::ActiveJob attr_reader :job_id def perform(exception, job_id) @job_id = job_id # ActiveJob calls rescue_with_handler when a job raises an exception rescue_with_handler(exception) || raise(exception) end end let(:exception) { StandardError.new('oh no') } let(:job_id) { "123" } it "reports the error to Rollbar" do expected_params = { :job => "TestJob", :job_id => job_id } expect(Rollbar).to receive(:error).with(exception, expected_params) TestJob.new.perform(exception, job_id) rescue nil end it "reraises the error so the job backend can handle the failure and retry" do expect { TestJob.new.perform(exception, job_id) }.to raise_error exception end end
Version data entries
19 entries across 19 versions & 1 rubygems