Updated RubySpec source to d6754b35 except language/def_spec.rb.
[rbx.git] / spec / frozen / 1.8 / library / net / ftp / abort_spec.rb
blob95fd3f3975b34ff475a834eb568fc76cf293b4f9
1 require File.dirname(__FILE__) + '/../../../spec_helper'
2 require 'net/ftp'
4 describe "Net::FTP#abort" do
5   before(:each) do
6     @socket = mock("Socket")
7     @socket.stub!(:send)
8     @socket.stub!(:readline).and_return("226 Closing data connection.")
9     
10     @ftp = Net::FTP.new
11     @ftp.instance_variable_set(:@sock, @socket)
12   end
13   
14   it "sends the ABOR command over the socket" do
15     @socket.should_receive(:send).with("ABOR\r\n", Socket::MSG_OOB)
16     @ftp.abort
17   end
18   
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"
22   end
23   
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.")
26     @ftp.abort
27   end
28   
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.")
31     @ftp.abort
32   end
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)
37   end
38   
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)
42   end
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)
47   end
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)
52   end
53 end