Sha256: 27fe865169993ec7428fce6cc279c1cb05622112eb8688e85105f840c13c9740
Contents?: true
Size: 1.45 KB
Versions: 8
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.2.2') require 'sidekiq' require 'sidekiq/cli' require 'airbrake/sidekiq' RSpec.describe "airbrake/sidekiq/error_handler" do let(:endpoint) do 'https://airbrake.io/api/v3/projects/113743/notices?key=fd04e13d806a90f96614ad8e529b2822' end def wait_for_a_request_with_body(body) wait_for(a_request(:post, endpoint).with(body: body)).to have_been_made.once end def call_handler handler = Sidekiq.error_handlers.last handler.call( AirbrakeTestError.new('sidekiq error'), 'class' => 'HardSidekiqWorker', 'args' => %w[bango bongo] ) end before do stub_request(:post, endpoint).to_return(status: 201, body: '{}') end it "sends a notice to Airbrake" do expect(call_handler).to be_a(Airbrake::Promise) wait_for_a_request_with_body(/"message":"sidekiq\serror"/) wait_for_a_request_with_body(/"params":{.*"args":\["bango","bongo"\]/) wait_for_a_request_with_body(/"component":"sidekiq","action":"HardSidekiqWorker"/) end context "when Airbrake is not configured" do before do @notifiers = Airbrake.instance_variable_get(:@notifiers) @default_notifier = @notifiers.delete(:default) end after do @notifiers[:default] = @default_notifier end it "returns nil" do expect(call_handler).to be_nil end end end end
Version data entries
8 entries across 8 versions & 1 rubygems