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-1.1.1 spec/translate_exceptions_spec.rb
ftpd-1.1.0 spec/translate_exceptions_spec.rb
investtools-ftpd-1.0.1 spec/translate_exceptions_spec.rb
ftpd-1.0.1 spec/translate_exceptions_spec.rb
ftpd-1.0.0 spec/translate_exceptions_spec.rb
ftpd-0.17.0 spec/translate_exceptions_spec.rb
ftpd-0.16.0 spec/translate_exceptions_spec.rb
ftpd-0.15.0 spec/translate_exceptions_spec.rb
ftpd-0.14.0 spec/translate_exceptions_spec.rb
ftpd-0.13.0 spec/translate_exceptions_spec.rb
ftpd-0.12.0 spec/translate_exceptions_spec.rb
ftpd-0.11.0 spec/translate_exceptions_spec.rb
ftpd-0.10.0 spec/translate_exceptions_spec.rb
ftpd-0.9.0 spec/translate_exceptions_spec.rb
ftpd-0.7.1 spec/translate_exceptions_spec.rb
ftpd-0.8.0 spec/translate_exceptions_spec.rb
ftpd-0.7.0 spec/translate_exceptions_spec.rb
ftpd-0.6.0 spec/translate_exceptions_spec.rb
ftpd-0.5.0 spec/translate_exceptions_spec.rb
ftpd-0.4.0 spec/translate_exceptions_spec.rb