Sha256: 954a9af888a47d254c64f8a18488c13b81d03a52c55c9201c4af76b7bd3f26f4

Contents?: true

Size: 870 Bytes

Versions: 24

Compression:

Stored size: 870 Bytes

Contents

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

module Ftpd
  describe TranslateExceptions do

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

    class Subject

      include TranslateExceptions

      def initialize
        translate_exception FooError
      end

      def raise_error(error, message)
        raise error, message
      end
      translate_exceptions :raise_error

    end

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

    it 'should translate a registered error' do
      expect {
        subject.raise_error(FooError, message)
      }.to raise_error PermanentFileSystemError, message
    end

    it 'should pass through an unregistered error' do
      expect {
        subject.raise_error(BarError, message)
      }.to raise_error BarError, message
    end

  end
end

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
ftpd-0.3.2 spec/translate_exceptions_spec.rb
ftpd-0.3.1 spec/translate_exceptions_spec.rb
ftpd-0.2.2 spec/translate_exceptions_spec.rb
ftpd-0.2.1 spec/translate_exceptions_spec.rb