module FTPMVC::TestHelpers
Public Instance Methods
get(ftp, path, encoding=nil)
click to toggle source
# File lib/ftpmvc/test_helpers.rb, line 21 def get(ftp, path, encoding=nil) ''.tap do |response| ftp.retrbinary("RETR #{path}", 1024) do |block| response << block end response.force_encoding(encoding) unless encoding.nil? end end
put(ftp, path, content)
click to toggle source
# File lib/ftpmvc/test_helpers.rb, line 30 def put(ftp, path, content) ftp.storlines("STOR #{path}", StringIO.new(content)) end
with_application(app) { |ftp| ... }
click to toggle source
# File lib/ftpmvc/test_helpers.rb, line 6 def with_application(app) server = FTPMVC::Server.new('127.0.0.1', 0).start_in_new_thread(app) begin ftp = Net::FTP.new begin ftp.connect('127.0.0.1', server.port) yield ftp ensure ftp.close rescue nil end ensure server.stop end end