Sha256: 3b1a5379e19196701df4318bfede8b91a77eed096f401152afa76ab5db9ed8e7

Contents?: true

Size: 1.31 KB

Versions: 8

Compression:

Stored size: 1.31 KB

Contents

require 'dandelion/backend/ftp'
require 'mocha'
require 'net/ftp'
require 'test/unit'

class TestFTP < Test::Unit::TestCase
  def setup
    @ftp = mock()
    Net::FTP.stubs(:open).returns(@ftp)
    @ftp.expects(:passive=).with(true).once
    @ftp.expects(:chdir).with('foo').once
    @backend = Dandelion::Backend::FTP.new('path' => 'foo')
    class << @backend
      def temp(file, data)
        yield(:temp)
      end
    end
  end
  
  def test_read
    @ftp.expects(:retrbinary).with('RETR bar', 4096).once
    @ftp.expects(:retrbinary).with('RETR bar/baz', 4096).once
    @ftp.expects(:retrbinary).with('RETR bar/baz/qux', 4096).once
    @backend.read('bar')
    @backend.read('bar/baz')
    @backend.read('bar/baz/qux')
  end
  
  def test_write
    @ftp.expects(:putbinaryfile).with(:temp, 'bar').once
    @ftp.expects(:putbinaryfile).with(:temp, 'bar/baz').once
    @backend.write('bar', 'baz')
    @backend.write('bar/baz', 'qux')
  end
  
  def test_delete
    @ftp.expects(:delete).with('bar').once
    @ftp.expects(:delete).with('bar/baz').once
    @ftp.expects(:delete).with('bar/baz/qux').once
    @ftp.expects(:rmdir).with('bar').twice
    @ftp.expects(:rmdir).with('bar/baz').once
    @backend.stubs(:empty?).returns(true)
    @backend.delete('bar')
    @backend.delete('bar/baz')
    @backend.delete('bar/baz/qux')
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dandelion-0.3.4 test/test_ftp.rb
dandelion-0.3.3 test/test_ftp.rb
dandelion-0.3.2 test/test_ftp.rb
dandelion-0.3.1 test/test_ftp.rb
dandelion-0.3.0 test/test_ftp.rb
dandelion-0.2.3 test/test_ftp.rb
dandelion-0.2.2 test/test_ftp.rb
dandelion-0.2.1 test/test_ftp.rb