Sha256: 0a0c538fd54971075b1a3feec372833fd20ec45371ca7c2c7aaadb6beb994109

Contents?: true

Size: 1.58 KB

Versions: 17

Compression:

Stored size: 1.58 KB

Contents

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

module Ftpd
  describe CommandSequenceChecker do

    let(:sequence_error) {[CommandError, '503 Bad sequence of commands']}
    subject(:checker) {CommandSequenceChecker.new}

    context 'initial' do

      it 'accepts any command' do
        checker.check 'NOOP'
      end

    end

    context 'when a specific command is expected' do
      
      before(:each) {checker.expect 'PASS'}

      it 'accepts that command' do
        checker.check 'PASS'
      end

      it 'rejects any other command' do
        expect {
          checker.check 'NOOP'
        }.to raise_error *sequence_error
      end

    end

    context 'after the expected command has arrived' do

      before(:each) do
        checker.expect 'PASS'
        checker.check 'PASS'
      end

      it 'accepts any other command' do
        checker.check 'NOOP'
      end

    end

    context 'after a command is rejected' do

      before(:each) do
        checker.expect 'PASS'
        expect {
          checker.check 'NOOP'
        }.to raise_error *sequence_error
      end

      it 'accepts any other command' do
        checker.check 'NOOP'
      end

    end

    context 'when a command must be expected' do

      before(:each) do
        checker.must_expect 'PASS'
      end

      it 'rejects that command if not expected' do
        expect {
          checker.check 'PASS'
        }.to raise_error *sequence_error
      end

      it 'accepts that command when it is accepted' do
        checker.expect 'PASS'
        checker.check 'PASS'
      end

    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

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