Sha256: 6dee65aaed8e9379459ef31aad466212233913056fc4d386a2007a3c85b3eb3c

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 Bytes

Contents

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

module Ftpd
  describe FileSystemErrorTranslator do

    class MockFileSystem

      def with_error
        raise FileSystemError, '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 'exception' do
      specify do
        expect {
          translator.with_error
        }.to raise_error CommandError, '450 An error occurred'
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ftpd-0.2.0 spec/file_system_error_translator_spec.rb