Sha256: 9cf9ea314f64b5514c1f3e596124d8c3229b7209605131fb4126cb89ef9d47c7

Contents?: true

Size: 933 Bytes

Versions: 2

Compression:

Stored size: 933 Bytes

Contents

# frozen_string_literal: true

require File.expand_path('spec_helper', File.dirname(__FILE__))

module Ftpd
  describe ExceptionTranslator do

    class FooError < StandardError ; end
    class BarError < StandardError ; end

    subject(:translator) {ExceptionTranslator.new}
    let(:message) {'An error happened'}

    context '(registered exception)' do
      before(:each) do
        translator.register_exception FooError
      end
      it 'should translate the exception' do
        expect {
          subject.translate_exceptions do
            raise FooError, message
          end
        }.to raise_error PermanentFileSystemError, message
      end
    end

    context '(unregistered exception)' do
      it 'should pass the exception' do
        expect {
          subject.translate_exceptions do
            raise BarError, message
          end
        }.to raise_error BarError, message
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ftpd-2.0.1 spec/exception_translator_spec.rb
ftpd-2.0.0 spec/exception_translator_spec.rb