rubysl-net-ftp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +25 -0
  6. data/README.md +29 -0
  7. data/Rakefile +1 -0
  8. data/lib/net/ftp.rb +1 -0
  9. data/lib/net/ftptls.rb +1 -0
  10. data/lib/rubysl/net/ftp.rb +2 -0
  11. data/lib/rubysl/net/ftp/ftp.rb +926 -0
  12. data/lib/rubysl/net/ftp/version.rb +7 -0
  13. data/rubysl-net-ftp.gemspec +23 -0
  14. data/spec/FTPError_spec.rb +7 -0
  15. data/spec/FTPPermError_spec.rb +11 -0
  16. data/spec/FTPProtoError_spec.rb +11 -0
  17. data/spec/FTPReplyError_spec.rb +11 -0
  18. data/spec/FTPTempError_spec.rb +11 -0
  19. data/spec/abort_spec.rb +61 -0
  20. data/spec/acct_spec.rb +57 -0
  21. data/spec/binary_spec.rb +23 -0
  22. data/spec/chdir_spec.rb +100 -0
  23. data/spec/close_spec.rb +29 -0
  24. data/spec/closed_spec.rb +20 -0
  25. data/spec/connect_spec.rb +48 -0
  26. data/spec/debug_mode_spec.rb +22 -0
  27. data/spec/delete_spec.rb +58 -0
  28. data/spec/dir_spec.rb +7 -0
  29. data/spec/fixtures/putbinaryfile +3 -0
  30. data/spec/fixtures/puttextfile +3 -0
  31. data/spec/fixtures/server.rb +265 -0
  32. data/spec/get_spec.rb +20 -0
  33. data/spec/getbinaryfile_spec.rb +7 -0
  34. data/spec/getdir_spec.rb +6 -0
  35. data/spec/gettextfile_spec.rb +7 -0
  36. data/spec/help_spec.rb +65 -0
  37. data/spec/initialize_spec.rb +86 -0
  38. data/spec/last_response_code_spec.rb +7 -0
  39. data/spec/last_response_spec.rb +24 -0
  40. data/spec/lastresp_spec.rb +7 -0
  41. data/spec/list_spec.rb +7 -0
  42. data/spec/login_spec.rb +215 -0
  43. data/spec/ls_spec.rb +7 -0
  44. data/spec/mdtm_spec.rb +37 -0
  45. data/spec/mkdir_spec.rb +60 -0
  46. data/spec/mtime_spec.rb +49 -0
  47. data/spec/nlst_spec.rb +120 -0
  48. data/spec/noop_spec.rb +37 -0
  49. data/spec/open_spec.rb +54 -0
  50. data/spec/passive_spec.rb +23 -0
  51. data/spec/put_spec.rb +20 -0
  52. data/spec/putbinaryfile_spec.rb +7 -0
  53. data/spec/puttextfile_spec.rb +7 -0
  54. data/spec/pwd_spec.rb +52 -0
  55. data/spec/quit_spec.rb +32 -0
  56. data/spec/rename_spec.rb +93 -0
  57. data/spec/resume_spec.rb +22 -0
  58. data/spec/retrbinary_spec.rb +29 -0
  59. data/spec/retrlines_spec.rb +33 -0
  60. data/spec/return_code_spec.rb +23 -0
  61. data/spec/rmdir_spec.rb +57 -0
  62. data/spec/sendcmd_spec.rb +53 -0
  63. data/spec/set_socket_spec.rb +7 -0
  64. data/spec/shared/getbinaryfile.rb +179 -0
  65. data/spec/shared/gettextfile.rb +129 -0
  66. data/spec/shared/last_response_code.rb +25 -0
  67. data/spec/shared/list.rb +133 -0
  68. data/spec/shared/putbinaryfile.rb +232 -0
  69. data/spec/shared/puttextfile.rb +149 -0
  70. data/spec/shared/pwd.rb +3 -0
  71. data/spec/site_spec.rb +52 -0
  72. data/spec/size_spec.rb +47 -0
  73. data/spec/status_spec.rb +62 -0
  74. data/spec/storbinary_spec.rb +47 -0
  75. data/spec/storlines_spec.rb +42 -0
  76. data/spec/system_spec.rb +47 -0
  77. data/spec/voidcmd_spec.rb +53 -0
  78. data/spec/welcome_spec.rb +24 -0
  79. metadata +243 -0
@@ -0,0 +1,49 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+
4
+ describe "Net::FTP#mtime" do
5
+ before(:each) do
6
+ @server = NetFTPSpecs::DummyFTP.new
7
+ @server.serve_once
8
+
9
+ @ftp = Net::FTP.new
10
+ @ftp.connect("localhost", 9921)
11
+ end
12
+
13
+ after(:each) do
14
+ @ftp.quit rescue nil
15
+ @ftp.close
16
+ @server.stop
17
+ end
18
+
19
+ it "sends the MDTM with the passed filename command to the server" do
20
+ @ftp.mtime("test.file")
21
+ @ftp.last_response.should == "213 19980705132316\n"
22
+ end
23
+
24
+ describe "when passed filename" do
25
+ it "returns the last modification time of the passed file as a Time object in the local time" do
26
+ @ftp.mtime("test.file").should == Time.gm("1998", "07", "05", "13", "23", "16")
27
+ end
28
+ end
29
+
30
+ describe "when passed filename, local_time" do
31
+ it "returns the last modification time as a Time object in UTC when local_time is true" do
32
+ @ftp.mtime("test.file", true).should == Time.local("1998", "07", "05", "13", "23", "16")
33
+ end
34
+
35
+ it "returns the last modification time as a Time object in the local time when local_time is false" do
36
+ @ftp.mtime("test.file", false).should == Time.gm("1998", "07", "05", "13", "23", "16")
37
+ end
38
+ end
39
+
40
+ it "raises a Net::FTPPermError when the response code is 550" do
41
+ @server.should_receive(:mdtm).and_respond("550 Requested action not taken.")
42
+ lambda { @ftp.mtime("test.file") }.should raise_error(Net::FTPPermError)
43
+ end
44
+
45
+ it "raises a Net::FTPTempError when the response code is 421" do
46
+ @server.should_receive(:mdtm).and_respond("421 Service not available, closing control connection.")
47
+ lambda { @ftp.mtime("test.file") }.should raise_error(Net::FTPTempError)
48
+ end
49
+ end
data/spec/nlst_spec.rb ADDED
@@ -0,0 +1,120 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+
4
+ describe "Net::FTP#nlst" do
5
+ before(:each) do
6
+ @server = NetFTPSpecs::DummyFTP.new
7
+ @server.serve_once
8
+
9
+ @ftp = Net::FTP.new
10
+ @ftp.passive = false
11
+ @ftp.connect("localhost", 9921)
12
+ end
13
+
14
+ after(:each) do
15
+ @ftp.quit rescue nil
16
+ @ftp.close
17
+ @server.stop
18
+ end
19
+
20
+ describe "when passed no arguments" do
21
+ it "returns an Array containing a list of files in the current dir" do
22
+ @ftp.nlst.should == ["last_response_code.rb", "list.rb", "pwd.rb"]
23
+ @ftp.last_response.should == "226 transfer complete (NLST)\n"
24
+ end
25
+ end
26
+
27
+ describe "when passed dir" do
28
+ it "returns an Array containing a list of files in the passed dir" do
29
+ @ftp.nlst("test.folder").should == ["last_response_code.rb", "list.rb", "pwd.rb"]
30
+ @ftp.last_response.should == "226 transfer complete (NLST test.folder)\n"
31
+ end
32
+ end
33
+
34
+ describe "when the NLST command fails" do
35
+ it "raises a Net::FTPTempError when the response code is 450" do
36
+ @server.should_receive(:nlst).and_respond("450 Requested file action not taken..")
37
+ lambda { @ftp.nlst }.should raise_error(Net::FTPTempError)
38
+ end
39
+
40
+ it "raises a Net::FTPPermError when the response code is 500" do
41
+ @server.should_receive(:nlst).and_respond("500 Syntax error, command unrecognized.")
42
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
43
+ end
44
+
45
+ it "raises a Net::FTPPermError when the response code is 501" do
46
+ @server.should_receive(:nlst).and_respond("501 Syntax error, command unrecognized.")
47
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
48
+ end
49
+
50
+ it "raises a Net::FTPPermError when the response code is 502" do
51
+ @server.should_receive(:nlst).and_respond("502 Command not implemented.")
52
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
53
+ end
54
+
55
+ it "raises a Net::FTPTempError when the response code is 421" do
56
+ @server.should_receive(:nlst).and_respond("421 Service not available, closing control connection.")
57
+ lambda { @ftp.nlst }.should raise_error(Net::FTPTempError)
58
+ end
59
+
60
+ it "raises a Net::FTPPermError when the response code is 530" do
61
+ @server.should_receive(:nlst).and_respond("530 Not logged in.")
62
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
63
+ end
64
+ end
65
+
66
+ ruby_version_is "" ... "1.9" do
67
+ describe "when switching type fails" do
68
+ it "raises a Net::FTPPermError when the response code is 500" do
69
+ @server.should_receive(:type).and_respond("500 Syntax error, command unrecognized.")
70
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
71
+ end
72
+
73
+ it "raises a Net::FTPPermError when the response code is 501" do
74
+ @server.should_receive(:type).and_respond("501 Syntax error in parameters or arguments.")
75
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
76
+ end
77
+
78
+ it "raises a Net::FTPPermError when the response code is 504" do
79
+ @server.should_receive(:type).and_respond("504 Command not implemented for that parameter.")
80
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
81
+ end
82
+
83
+ it "raises a Net::FTPTempError when the response code is 421" do
84
+ @server.should_receive(:type).and_respond("421 Service not available, closing control connection.")
85
+ lambda { @ftp.nlst }.should raise_error(Net::FTPTempError)
86
+ end
87
+
88
+ it "raises a Net::FTPPermError when the response code is 530" do
89
+ @server.should_receive(:type).and_respond("530 Not logged in.")
90
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
91
+ end
92
+ end
93
+ end
94
+
95
+ describe "when opening the data port fails" do
96
+ it "raises a Net::FTPPermError when the response code is 500" do
97
+ @server.should_receive(:eprt).and_respond("500 Syntax error, command unrecognized.")
98
+ @server.should_receive(:port).and_respond("500 Syntax error, command unrecognized.")
99
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
100
+ end
101
+
102
+ it "raises a Net::FTPPermError when the response code is 501" do
103
+ @server.should_receive(:eprt).and_respond("501 Syntax error in parameters or arguments.")
104
+ @server.should_receive(:port).and_respond("501 Syntax error in parameters or arguments.")
105
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
106
+ end
107
+
108
+ it "raises a Net::FTPTempError when the response code is 421" do
109
+ @server.should_receive(:eprt).and_respond("421 Service not available, closing control connection.")
110
+ @server.should_receive(:port).and_respond("421 Service not available, closing control connection.")
111
+ lambda { @ftp.nlst }.should raise_error(Net::FTPTempError)
112
+ end
113
+
114
+ it "raises a Net::FTPPermError when the response code is 530" do
115
+ @server.should_receive(:eprt).and_respond("530 Not logged in.")
116
+ @server.should_receive(:port).and_respond("530 Not logged in.")
117
+ lambda { @ftp.nlst }.should raise_error(Net::FTPPermError)
118
+ end
119
+ end
120
+ end
data/spec/noop_spec.rb ADDED
@@ -0,0 +1,37 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+
4
+ describe "Net::FTP#noop" do
5
+ before(:each) do
6
+ @server = NetFTPSpecs::DummyFTP.new
7
+ @server.serve_once
8
+
9
+ @ftp = Net::FTP.new
10
+ @ftp.connect("localhost", 9921)
11
+ end
12
+
13
+ after(:each) do
14
+ @ftp.quit rescue nil
15
+ @ftp.close
16
+ @server.stop
17
+ end
18
+
19
+ it "sends the NOOP command to the server" do
20
+ @ftp.noop
21
+ @ftp.last_response.should == "200 Command okay. (NOOP)\n"
22
+ end
23
+
24
+ it "returns nil" do
25
+ @ftp.noop.should be_nil
26
+ end
27
+
28
+ it "raises a Net::FTPPermError when the response code is 500" do
29
+ @server.should_receive(:noop).and_respond("500 Syntax error, command unrecognized.")
30
+ lambda { @ftp.noop }.should raise_error(Net::FTPPermError)
31
+ end
32
+
33
+ it "raises a Net::FTPTempError when the response code is 421" do
34
+ @server.should_receive(:noop).and_respond("421 Service not available, closing control connection.")
35
+ lambda { @ftp.noop }.should raise_error(Net::FTPTempError)
36
+ end
37
+ end
data/spec/open_spec.rb ADDED
@@ -0,0 +1,54 @@
1
+ require 'net/ftp'
2
+
3
+ describe "Net::FTP.open" do
4
+ before(:each) do
5
+ @ftp = mock("Net::FTP instance")
6
+ Net::FTP.stub!(:new).and_return(@ftp)
7
+ end
8
+
9
+ describe "when passed no block" do
10
+ it "returns a new Net::FTP instance" do
11
+ Net::FTP.open("localhost").should equal(@ftp)
12
+ end
13
+
14
+ it "passes the passed arguments down to Net::FTP.new" do
15
+ Net::FTP.should_receive(:new).with("localhost", "user", "password", "account")
16
+ Net::FTP.open("localhost", "user", "password", "account")
17
+ end
18
+ end
19
+
20
+ describe "when passed a block" do
21
+ before(:each) do
22
+ @ftp.stub!(:close)
23
+ end
24
+
25
+ it "yields a new Net::FTP instance to the passed block" do
26
+ yielded = false
27
+ Net::FTP.open("localhost") do |ftp|
28
+ yielded = true
29
+ ftp.should equal(@ftp)
30
+ end
31
+ yielded.should be_true
32
+ end
33
+
34
+ it "closes the Net::FTP instance after yielding" do
35
+ Net::FTP.open("localhost") do |ftp|
36
+ ftp.should_receive(:close)
37
+ end
38
+ end
39
+
40
+ it "closes the Net::FTP instance even if an exception is raised while yielding" do
41
+ begin
42
+ Net::FTP.open("localhost") do |ftp|
43
+ ftp.should_receive(:close)
44
+ raise ArgumentError, "some exception"
45
+ end
46
+ rescue ArgumentError
47
+ end
48
+ end
49
+
50
+ it "returns the block's return value" do
51
+ Net::FTP.open("localhost") { :test }.should == :test
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,23 @@
1
+ require 'net/ftp'
2
+
3
+ describe "Net::FTP#passive" do
4
+ it "returns true when self is in passive mode" do
5
+ ftp = Net::FTP.new
6
+ ftp.passive.should be_false
7
+
8
+ ftp.passive = true
9
+ ftp.passive.should be_true
10
+ end
11
+ end
12
+
13
+ describe "Net::FTP#passive=" do
14
+ it "sets self to passive mode when passed true" do
15
+ ftp = Net::FTP.new
16
+
17
+ ftp.passive = true
18
+ ftp.passive.should be_true
19
+
20
+ ftp.passive = false
21
+ ftp.passive.should be_false
22
+ end
23
+ end
data/spec/put_spec.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+ require File.expand_path('../shared/puttextfile', __FILE__)
4
+ require File.expand_path('../shared/putbinaryfile', __FILE__)
5
+
6
+ describe "Net::FTP#put (binary mode)" do
7
+ before(:each) do
8
+ @binary_mode = true
9
+ end
10
+
11
+ it_behaves_like :net_ftp_putbinaryfile, :put
12
+ end
13
+
14
+ describe "Net::FTP#put (text mode)" do
15
+ before(:each) do
16
+ @binary_mode = false
17
+ end
18
+
19
+ it_behaves_like :net_ftp_puttextfile, :put
20
+ end
@@ -0,0 +1,7 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+ require File.expand_path('../shared/putbinaryfile', __FILE__)
4
+
5
+ describe "Net::FTP#putbinaryfile" do
6
+ it_behaves_like :net_ftp_putbinaryfile, :putbinaryfile
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+ require File.expand_path('../shared/puttextfile', __FILE__)
4
+
5
+ describe "Net::FTP#puttextfile" do
6
+ it_behaves_like :net_ftp_puttextfile, :puttextfile
7
+ end
data/spec/pwd_spec.rb ADDED
@@ -0,0 +1,52 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+
4
+ describe "Net::FTP#pwd" do
5
+ before(:each) do
6
+ @server = NetFTPSpecs::DummyFTP.new
7
+ @server.serve_once
8
+
9
+ @ftp = Net::FTP.new
10
+ @ftp.connect("localhost", 9921)
11
+ end
12
+
13
+ after(:each) do
14
+ @ftp.quit rescue nil
15
+ @ftp.close
16
+ @server.stop
17
+ end
18
+
19
+ it "sends the PWD command to the server" do
20
+ @ftp.pwd
21
+ @ftp.last_response.should == "257 \"/some/dir/\" - current directory\n"
22
+ end
23
+
24
+ it "returns the current directory" do
25
+ @ftp.pwd.should == "/some/dir/"
26
+ end
27
+
28
+ it "raises a Net::FTPPermError when the response code is 500" do
29
+ @server.should_receive(:pwd).and_respond("500 Syntax error, command unrecognized.")
30
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
31
+ end
32
+
33
+ it "raises a Net::FTPPermError when the response code is 501" do
34
+ @server.should_receive(:pwd).and_respond("501 Syntax error in parameters or arguments.")
35
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
36
+ end
37
+
38
+ it "raises a Net::FTPPermError when the response code is 502" do
39
+ @server.should_receive(:pwd).and_respond("502 Command not implemented.")
40
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
41
+ end
42
+
43
+ it "raises a Net::FTPTempError when the response code is 421" do
44
+ @server.should_receive(:pwd).and_respond("421 Service not available, closing control connection.")
45
+ lambda { @ftp.pwd }.should raise_error(Net::FTPTempError)
46
+ end
47
+
48
+ it "raises a Net::FTPPermError when the response code is 550" do
49
+ @server.should_receive(:pwd).and_respond("550 Requested action not taken.")
50
+ lambda { @ftp.pwd }.should raise_error(Net::FTPPermError)
51
+ end
52
+ end
data/spec/quit_spec.rb ADDED
@@ -0,0 +1,32 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+
4
+ describe "Net::FTP#quit" do
5
+ before(:each) do
6
+ @server = NetFTPSpecs::DummyFTP.new
7
+ @server.serve_once
8
+
9
+ @ftp = Net::FTP.new
10
+ @ftp.connect("localhost", 9921)
11
+ end
12
+
13
+ after(:each) do
14
+ @ftp.quit rescue nil
15
+ @ftp.close
16
+ @server.stop
17
+ end
18
+
19
+ it "sends the QUIT command to the server" do
20
+ @ftp.quit
21
+ @ftp.last_response.should == "221 OK, bye\n"
22
+ end
23
+
24
+ it "does not close the socket automagically" do
25
+ @ftp.quit
26
+ @ftp.closed?.should be_false
27
+ end
28
+
29
+ it "returns nil" do
30
+ @ftp.quit.should be_nil
31
+ end
32
+ end
@@ -0,0 +1,93 @@
1
+ require 'net/ftp'
2
+ require File.expand_path('../fixtures/server', __FILE__)
3
+
4
+ describe "Net::FTP#rename" do
5
+ before(:each) do
6
+ @server = NetFTPSpecs::DummyFTP.new
7
+ @server.serve_once
8
+
9
+ @ftp = Net::FTP.new
10
+ @ftp.connect("localhost", 9921)
11
+ end
12
+
13
+ after(:each) do
14
+ @ftp.quit rescue nil
15
+ @ftp.close
16
+ @server.stop
17
+ end
18
+
19
+ describe "when passed from_name, to_name" do
20
+ it "sends the RNFR command with the passed from_name and the RNTO command with the passed to_name to the server" do
21
+ @ftp.rename("from.file", "to.file")
22
+ @ftp.last_response.should == "250 Requested file action okay, completed. (Renamed from.file to to.file)\n"
23
+ end
24
+
25
+ it "returns something" do
26
+ @ftp.rename("from.file", "to.file").should be_nil
27
+ end
28
+ end
29
+
30
+ describe "when the RNFR command fails" do
31
+ it "raises a Net::FTPTempError when the response code is 450" do
32
+ @server.should_receive(:rnfr).and_respond("450 Requested file action not taken.")
33
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
34
+ end
35
+
36
+ it "raises a Net::FTPPermError when the response code is 550" do
37
+ @server.should_receive(:rnfr).and_respond("550 Requested action not taken.")
38
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
39
+ end
40
+
41
+ it "raises a Net::FTPPermError when the response code is 501" do
42
+ @server.should_receive(:rnfr).and_respond("501 Syntax error in parameters or arguments.")
43
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
44
+ end
45
+
46
+ it "raises a Net::FTPPermError when the response code is 502" do
47
+ @server.should_receive(:rnfr).and_respond("502 Command not implemented.")
48
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
49
+ end
50
+
51
+ it "raises a Net::FTPTempError when the response code is 421" do
52
+ @server.should_receive(:rnfr).and_respond("421 Service not available, closing control connection.")
53
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
54
+ end
55
+
56
+ it "raises a Net::FTPPermError when the response code is 530" do
57
+ @server.should_receive(:rnfr).and_respond("530 Not logged in.")
58
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
59
+ end
60
+ end
61
+
62
+ describe "when the RNTO command fails" do
63
+ it "raises a Net::FTPPermError when the response code is 532" do
64
+ @server.should_receive(:rnfr).and_respond("532 Need account for storing files.")
65
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
66
+ end
67
+
68
+ it "raises a Net::FTPPermError when the response code is 553" do
69
+ @server.should_receive(:rnto).and_respond("553 Requested action not taken.")
70
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
71
+ end
72
+
73
+ it "raises a Net::FTPPermError when the response code is 501" do
74
+ @server.should_receive(:rnto).and_respond("501 Syntax error in parameters or arguments.")
75
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
76
+ end
77
+
78
+ it "raises a Net::FTPPermError when the response code is 502" do
79
+ @server.should_receive(:rnto).and_respond("502 Command not implemented.")
80
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
81
+ end
82
+
83
+ it "raises a Net::FTPTempError when the response code is 421" do
84
+ @server.should_receive(:rnto).and_respond("421 Service not available, closing control connection.")
85
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPTempError)
86
+ end
87
+
88
+ it "raises a Net::FTPPermError when the response code is 530" do
89
+ @server.should_receive(:rnto).and_respond("530 Not logged in.")
90
+ lambda { @ftp.rename("from.file", "to.file") }.should raise_error(Net::FTPPermError)
91
+ end
92
+ end
93
+ end