1 require File.dirname(__FILE__) + '/../../../spec_helper'
4 describe "Net::FTP#abort" do
6 @socket = mock("Socket")
8 @socket.stub!(:readline).and_return("226 Closing data connection.")
11 @ftp.instance_variable_set(:@sock, @socket)
14 it "sends the ABOR command over the socket" do
15 @socket.should_receive(:send).with("ABOR\r\n", Socket::MSG_OOB)
19 it "returns the full response" do
20 @socket.should_receive(:readline).and_return("226 Closing data connection.")
21 @ftp.abort.should == "226 Closing data connection.\n"
24 it "does not raise any error when the response code is 226" do
25 @socket.should_receive(:readline).and_return("225 Data connection open; no transfer in progress.")
29 it "does not raise any error when the response code is 226" do
30 @socket.should_receive(:readline).and_return("226 Closing data connection.")
34 it "raises a Net::FTPProtoError when the response code is 500" do
35 @socket.should_receive(:readline).and_return("500 Syntax error, command unrecognized.")
36 lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)
39 it "raises a Net::FTPProtoError when the response code is 501" do
40 @socket.should_receive(:readline).and_return("501 Syntax error in parameters or arguments.")
41 lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)
44 it "raises a Net::FTPProtoError when the response code is 502" do
45 @socket.should_receive(:readline).and_return("502 Command not implemented.")
46 lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)
49 it "raises a Net::FTPProtoError when the response code is 421" do
50 @socket.should_receive(:readline).and_return("421 Service not available, closing control connection.")
51 lambda { @ftp.abort }.should raise_error(Net::FTPProtoError)