Sha256: 8b25b2f5b0f101ab362dcbf24482d14ca088991cb69d9800225b7e5319acec19
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
airbrake-6.1.2 | spec/unit/sidekiq_spec.rb |
airbrake-6.1.1 | spec/unit/sidekiq_spec.rb |
airbrake-6.1.0 | spec/unit/sidekiq_spec.rb |
airbrake-6.1.0.rc.1 | spec/unit/sidekiq_spec.rb |