blob: f9eefcd988a9719073227c8334313609e384b07c (
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
|
require "net/ftp"
require "test/unit"
require "ostruct"
require "stringio"
class FTPTest < Test::Unit::TestCase
def test_gets_empty
sock = create_buffered_socket("")
assert_equal(nil, sock.gets)
end
def test_gets_one_line
sock = create_buffered_socket("foo\n")
assert_equal("foo\n", sock.gets)
end
def test_gets_one_line_without_term
sock = create_buffered_socket("foo")
assert_equal("foo", sock.gets)
end
def test_gets_two_lines
sock = create_buffered_socket("foo\nbar\n")
assert_equal("foo\n", sock.gets)
assert_equal("bar\n", sock.gets)
end
def test_gets_two_lines_without_term
sock = create_buffered_socket("foo\nbar")
assert_equal("foo\n", sock.gets)
assert_equal("bar", sock.gets)
end
private
def create_buffered_socket(s)
io = StringIO.new(s)
return Net::FTP::BufferedSocket.new(io)
end
end
|