Sha256: 8cba466005be28acd38a965c4f57541cffd1fa6b96fc91532f8aa864dd6331cf

Contents?: true

Size: 1.24 KB

Versions: 18

Compression:

Stored size: 1.24 KB

Contents

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

module Ftpd
  describe FileSystemErrorTranslator do

    class MockFileSystem

      def with_error(klass)
        raise klass, 'An error occurred'
      end

      def without_error
        123
      end

    end

    subject(:translator) do
      FileSystemErrorTranslator.new(MockFileSystem.new)
    end

    context 'missing method' do
      specify do
        expect {
          translator.no_such_method
        }.to raise_error NoMethodError, /no_such_method/
      end
    end

    context 'no exception' do
      its(:without_error) {should == 123}
    end

    context 'FileSystemError' do
      specify do
        expect {
          translator.with_error(FileSystemError)
        }.to raise_error CommandError, '550 An error occurred'
      end
    end

    context 'PermanentFileSystemError' do
      specify do
        expect {
          translator.with_error(PermanentFileSystemError)
        }.to raise_error CommandError, '550 An error occurred'
      end
    end

    context 'TransientFileSystemError' do
      specify do
        expect {
          translator.with_error(TransientFileSystemError)
        }.to raise_error CommandError, '450 An error occurred'
      end
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
ftpd-0.16.0 spec/file_system_error_translator_spec.rb
ftpd-0.15.0 spec/file_system_error_translator_spec.rb
ftpd-0.14.0 spec/file_system_error_translator_spec.rb
ftpd-0.13.0 spec/file_system_error_translator_spec.rb
ftpd-0.12.0 spec/file_system_error_translator_spec.rb
ftpd-0.11.0 spec/file_system_error_translator_spec.rb
ftpd-0.10.0 spec/file_system_error_translator_spec.rb
ftpd-0.9.0 spec/file_system_error_translator_spec.rb
ftpd-0.7.1 spec/file_system_error_translator_spec.rb
ftpd-0.8.0 spec/file_system_error_translator_spec.rb
ftpd-0.7.0 spec/file_system_error_translator_spec.rb
ftpd-0.6.0 spec/file_system_error_translator_spec.rb
ftpd-0.5.0 spec/file_system_error_translator_spec.rb
ftpd-0.4.0 spec/file_system_error_translator_spec.rb
ftpd-0.3.2 spec/file_system_error_translator_spec.rb
ftpd-0.3.1 spec/file_system_error_translator_spec.rb
ftpd-0.2.2 spec/file_system_error_translator_spec.rb
ftpd-0.2.1 spec/file_system_error_translator_spec.rb