Clone this wiki locally
While working on a Rails project, I found myself wanting to write tests around the ability to upload a feed file to an external FTP server. After reading about rumbster (https://github.com/sr/rumbster), I really wanted something like that for FTP. At the time, I was reduced to stubbing Net::FTP.
FakeFtp is a single-client server that accepts a minimum of FTP commands necessary for file upload. Files are not currently stored by the server, but are tracked in the server's :files accessor.
require 'fake_ftp' require 'net/ftp' server = FakeFtp::Server.new(21212, 21213) ## 21212 is the control port, which is used by FTP for the primary connection ## 21213 is the data port, used in FTP passive mode to send file contents server.start ftp = Net::FTP.new ftp.connect('127.0.0.1', 21212) ftp.login('user', 'password') ftp.passive = true ftp.put('/dir/to/some_file.txt') ftp.close server.files.should include('some_file.txt') server.file('some_file.txt').bytes.should == 35 server.stop
Fork the project on github, then send a pull request for any commits you make. Note that commits will not be integrated without tests.