Sha256: 69b51f2d503ee9290b86a5eff73ad5107d78392333404d8b8ee15ba45bf83790

Contents?: true

Size: 929 Bytes

Versions: 1

Compression:

Stored size: 929 Bytes

Contents

require 'rails_helper'

RSpec.describe Whoopsie, type: :module do
  context '#report_and_swallow' do
    it "calls 'handle_exception' for raised exceptions" do
      expect(Whoopsie).to receive(:handle_exception)
      Whoopsie.report_and_swallow do
        X = 10 / 0
      end
    end

    context 'when Whoopsie is enabled' do
      before do
        Rails.application.config.whoopsie.enable = true
      end

      it 'swallows the exception' do
        expect do
          Whoopsie.report_and_swallow do
            X = 10 / 0
          end
        end.to_not raise_error
      end
    end

    context 'when Whoopsie is disabled' do
      before do
        Rails.application.config.whoopsie.enable = false
      end

      it 'raises the exception' do
        expect do
          Whoopsie.report_and_swallow do
            X = 10 / 0
          end
        end.to raise_error(ZeroDivisionError)
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
whoopsie-0.0.2 spec/lib/whoopsie_spec.rb