Sha256: a6b14a97dcb594e327d23811913b7c9c51e463d95d755823f674382904543bf6

Contents?: true

Size: 1015 Bytes

Versions: 11

Compression:

Stored size: 1015 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')

class FileDownloaderTest < Test::Unit::TestCase
  setup do
    @downloader, @tempfile = mock_downloader(Vagrant::Downloaders::File)
    @uri = "foo.box"
  end

  context "downloading" do
    setup do
      @file = mock("file")
      @file.stubs(:read)
      @file.stubs(:eof?).returns(false)
      @downloader.stubs(:open).yields(@file)
    end

    should "open with the given uri" do
      @downloader.expects(:open).with(@uri).once
      @downloader.download!(@uri, @tempfile)
    end

    should "buffer the read from the file and write to the tempfile" do
      data = mock("data")
      write_seq = sequence("write_seq")
      @file.stubs(:eof?).returns(false).in_sequence(write_seq)
      @file.expects(:read).returns(data).in_sequence(write_seq)
      @tempfile.expects(:write).with(data).in_sequence(write_seq)
      @file.stubs(:eof?).returns(true).in_sequence(write_seq)
      @downloader.download!(@uri, @tempfile)
    end
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
vagrantup-0.1.4 test/vagrant/downloaders/file_test.rb
vagrantup-0.1.3 test/vagrant/downloaders/file_test.rb
vagrantup-0.1.2 test/vagrant/downloaders/file_test.rb
vagrantup-0.1.1 test/vagrant/downloaders/file_test.rb
vagrantup-0.1.0 test/vagrant/downloaders/file_test.rb
vagrant-0.1.4 test/vagrant/downloaders/file_test.rb
vagrant-0.1.4.pre.a test/vagrant/downloaders/file_test.rb
vagrant-0.1.3 test/vagrant/downloaders/file_test.rb
vagrant-0.1.2 test/vagrant/downloaders/file_test.rb
vagrant-0.1.1 test/vagrant/downloaders/file_test.rb
vagrant-0.1.0 test/vagrant/downloaders/file_test.rb