Sha256: 7028f845e3778774f73316e88cd51529b4927efc875328d22ad807f52067bd5f

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module LightServiceExt
  RSpec.describe WithErrorHandler do
    let(:implementor_class) do
      Class.new do
        extend WithErrorHandler
      end
    end

    let(:ctx) { ApplicationContext.make_with_defaults }

    before do
      allow(ctx).to receive(:organized_by) { ApplicationOrganizer }
      allow(ctx).to receive(:invoked_action) { ApplicationAction }
    end

    describe '.with_error_handler' do
      let(:error_message) { 'some-error' }
      let(:error) { RuntimeError.new(error_message) }
      let(:results_ctx_proc) { -> { raise error } }

      subject(:raised_error_handled_ctx) do
        implementor_class.with_error_handler(ctx: ctx, &results_ctx_proc)
      end

      before { allow(ctx).to receive(:record_raised_error) }

      it 'fails context and records error' do
        expect(raised_error_handled_ctx.failure?).to be_truthy
        expect(raised_error_handled_ctx).to have_received(:record_raised_error).with(error)
        expect(raised_error_handled_ctx.status).to eql(Status::COMPLETE)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
light-service-ext-0.1.11 spec/light-service-ext/with_error_handler_spec.rb
light-service-ext-0.1.10 spec/light-service-ext/with_error_handler_spec.rb
light-service-ext-0.1.9 spec/light-service-ext/with_error_handler_spec.rb