Sha256: a7cd67bdbb76da3587eee3f700c91f7575a5c6d631b079200a8de28dca0f46da

Contents?: true

Size: 852 Bytes

Versions: 3

Compression:

Stored size: 852 Bytes

Contents

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

module Ftpd
  describe ExceptionTranslator do

    class FooError < 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 FileSystemError, 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

3 entries across 3 versions & 1 rubygems

Version Path
ftpd-0.2.0 spec/exception_translator_spec.rb
ftpd-0.1.1 spec/exception_translator_spec.rb
ftpd-0.1.0 spec/exception_translator_spec.rb