Sha256: 1669e71bdd200a30007756927fcfc79c8a6e572f6c66f8be6d367152c741516e
Contents?: true
Size: 1.75 KB
Versions: 2
Compression:
Stored size: 1.75 KB
Contents
# frozen_string_literal: true require File.expand_path('spec_helper', File.dirname(__FILE__)) module Ftpd describe CommandSequenceChecker do let(:sequence_error_verification) do lambda {|e| e.code == 503 && e.message == "Bad sequence of commands"} end 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(FtpServerError, &sequence_error_verification) 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(FtpServerError, &sequence_error_verification) 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(FtpServerError, &sequence_error_verification) end it 'accepts that command when it is accepted' do checker.expect 'PASS' checker.check 'PASS' end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ftpd-2.0.1 | spec/command_sequence_checker_spec.rb |
ftpd-2.0.0 | spec/command_sequence_checker_spec.rb |