summaryrefslogtreecommitdiff
path: root/spec/ruby/library/net/ftp/size_spec.rb
blob: 17615079e928713786915233135765e60b1c988d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require_relative '../../../spec_helper'
require_relative 'spec_helper'
require_relative 'fixtures/server'

describe "Net::FTP#size" do
  before :each do
    @server = NetFTPSpecs::DummyFTP.new
    @server.serve_once

    @ftp = Net::FTP.new
    @ftp.connect(@server.hostname, @server.server_port)
  end

  after :each do
    @ftp.quit rescue nil
    @ftp.close
    @server.stop
  end

  it "sends the SIZE command to the server" do
    @ftp.size("test.file")
    @ftp.last_response.should == "213 1024\n"
  end

  it "returns the size of the passed file as Integer" do
    @ftp.size("test.file").should eql(1024)
  end

  it "raises a Net::FTPPermError when the response code is 500" do
    @server.should_receive(:size).and_respond("500 Syntax error, command unrecognized.")
    -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
  end

  it "raises a Net::FTPPermError when the response code is 501" do
    @server.should_receive(:size).and_respond("501 Syntax error in parameters or arguments.")
    -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
  end

  it "raises a Net::FTPTempError when the response code is 421" do
    @server.should_receive(:size).and_respond("421 Service not available, closing control connection.")
    -> { @ftp.size("test.file") }.should raise_error(Net::FTPTempError)
  end

  it "raises a Net::FTPPermError when the response code is 550" do
    @server.should_receive(:size).and_respond("550 Requested action not taken.")
    -> { @ftp.size("test.file") }.should raise_error(Net::FTPPermError)
  end
end
stat' width='100%'> -rw-r--r--ext/Win32API/lib/win32/registry.rb2
-rw-r--r--ext/Win32API/lib/win32/resolv.rb2
-rw-r--r--ext/bigdecimal/bigdecimal.c59
-rw-r--r--ext/bigdecimal/extconf.rb10
-rw-r--r--ext/dl/ptr.c36
-rw-r--r--ext/iconv/iconv.c5
-rw-r--r--ext/pty/lib/expect.rb2
-rw-r--r--ext/readline/extconf.rb7
-rw-r--r--ext/readline/readline.c19
-rw-r--r--ext/syck/rubyext.c1
-rw-r--r--ext/zlib/zlib.c2
-rw-r--r--file.c52
-rw-r--r--gc.c16
-rw-r--r--io.c36
-rw-r--r--lib/benchmark.rb7
-rw-r--r--lib/cgi.rb8
-rw-r--r--lib/date.rb4
-rw-r--r--lib/delegate.rb22
-rw-r--r--lib/irb.rb18
-rw-r--r--lib/mkmf.rb2
-rw-r--r--lib/net/pop.rb2
-rw-r--r--lib/net/telnet.rb13
-rw-r--r--lib/resolv.rb3
-rw-r--r--lib/timeout.rb23
-rw-r--r--lib/uri/common.rb2
-rw-r--r--lib/uri/generic.rb3
-rw-r--r--lib/xmlrpc/server.rb6
-rw-r--r--lib/yaml.rb4
-rw-r--r--lib/yaml/basenode.rb2
-rw-r--r--lib/yaml/rubytypes.rb18
-rw-r--r--lib/yaml/types.rb8
-rw-r--r--marshal.c41
-rw-r--r--misc/ruby-mode.el2
-rw-r--r--missing/strftime.c56
-rw-r--r--numeric.c29
-rw-r--r--object.c1
-rw-r--r--parse.y35
-rw-r--r--process.c3
-rw-r--r--re.c7
-rw-r--r--regex.c4
-rw-r--r--signal.c22
-rw-r--r--sprintf.c4
-rw-r--r--string.c2
-rw-r--r--struct.c13
-rw-r--r--test/ruby/test_beginendblock.rb12
-rw-r--r--test/ruby/test_bignum.rb8
-rw-r--r--test/yaml/test_yaml.rb8
-rw-r--r--time.c6
-rw-r--r--util.c3411
-rw-r--r--version.h8
-rw-r--r--win32/win32.c276
58 files changed, 601 insertions, 4342 deletions