Sha256: 4fa31dc0f9b4dcdedfdd7a622b99b9d1e48e7c5f69df968945215dba17a56258

Contents?: true

Size: 762 Bytes

Versions: 2

Compression:

Stored size: 762 Bytes

Contents

require 'net/ftp'
require File.expand_path('../fixtures/server', __FILE__)

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

    @ftp = Net::FTP.new
    @ftp.connect("localhost", 9921)
  end

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

  it "sends the passed command to the server" do
    @ftp.retrbinary("RETR test", 4096) {}
    @ftp.last_response.should == "226 Closing data connection. (RETR test)\n"
  end

  it "yields the received content as binary blocks of the passed size" do
    res = []
    @ftp.retrbinary("RETR test", 10) { |bin| res << bin }
    res.should == [ "This is th", "e content\n", "of the fil", "e named 't", "est'.\n" ]
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysl-net-ftp-2.0.1 spec/retrbinary_spec.rb
rubysl-net-ftp-1.0.0 spec/retrbinary_spec.rb