Sha256: fea1e3d2679244592240109e49864fecc2663e5ae7624748800e47a6b94675c7

Contents?: true

Size: 1.58 KB

Versions: 63

Compression:

Stored size: 1.58 KB

Contents

require 'rails_helper'

describe LHC::Rollbar do
  before(:each) do
    LHC.config.interceptors = [LHC::Rollbar]
  end

  it 'does not report if Rollbar is not defined' do
    stub_request(:get, 'http://local.ch').to_return(status: 400)
    expect(-> { LHC.get('http://local.ch') })
      .to raise_error LHC::BadRequest
  end

  context 'Rollbar is defined' do
    before(:each) do
      class Rollbar; end
      allow(::Rollbar).to receive(:warning)
    end

    it 'does report errors to rollbar' do
      stub_request(:get, 'http://local.ch').to_return(status: 400)
      expect(-> { LHC.get('http://local.ch') })
        .to raise_error LHC::BadRequest
      expect(::Rollbar).to have_received(:warning)
        .with(
          'Status: 400 URL: http://local.ch',
          response: hash_including(body: anything, code: anything, headers: anything, time: anything, timeout?: anything),
          request: hash_including(url: anything, method: anything, headers: anything, params: anything)
        )
    end

    context 'additional params' do
      it 'does report errors to rollbar with additional data' do
        stub_request(:get, 'http://local.ch')
          .to_return(status: 400)
        expect(-> { LHC.get('http://local.ch', rollbar: { additional: 'data' }) })
          .to raise_error LHC::BadRequest
        expect(::Rollbar).to have_received(:warning)
          .with(
            'Status: 400 URL: http://local.ch',
            hash_including(
              response: anything,
              request: anything,
              additional: 'data'
            )
          )
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 2 rubygems

Version Path
lhc-10.1.2 spec/interceptors/rollbar/main_spec.rb
lhc-10.1.1 spec/interceptors/rollbar/main_spec.rb
lhc-10.1.0 spec/interceptors/rollbar/main_spec.rb
lhc-10.0.2 spec/interceptors/rollbar/main_spec.rb
lhc-9.4.4 spec/interceptors/rollbar/main_spec.rb
lhc-10.0.1 spec/interceptors/rollbar/main_spec.rb
lhc-10.0.0 spec/interceptors/rollbar/main_spec.rb
lhc-9.4.3 spec/interceptors/rollbar/main_spec.rb
lhc-9.4.2 spec/interceptors/rollbar/main_spec.rb
lhc-9.4.1 spec/interceptors/rollbar/main_spec.rb
lhc-9.4.0 spec/interceptors/rollbar/main_spec.rb
lhc-9.3.1 spec/interceptors/rollbar/main_spec.rb
lhc-9.3.0 spec/interceptors/rollbar/main_spec.rb
lhc-9.2.0 spec/interceptors/rollbar/main_spec.rb
lhc-9.1.2 spec/interceptors/rollbar/main_spec.rb
lhc-9.1.2.pre spec/interceptors/rollbar/main_spec.rb
lhc-9.1.1 spec/interceptors/rollbar/main_spec.rb
lhc-8.1.1 spec/interceptors/rollbar/main_spec.rb
lhc-9.1.0 spec/interceptors/rollbar/main_spec.rb
lhc-9.0.0 spec/interceptors/rollbar/main_spec.rb