Sha256: 7aa7af9f94fffcbc5c36c7f9eb15a8af6cd9f3f811d36a04c9ac822d4dd33e7d

Contents?: true

Size: 1.21 KB

Versions: 40

Compression:

Stored size: 1.21 KB

Contents

require "test_helper"

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

  context "preparing" do
    should "raise an exception if the file does not exist" do
      File.expects(:file?).with(@uri).returns(false)

      assert_raises(Vagrant::Errors::DownloaderFileDoesntExist) {
        @downloader.prepare(@uri)
      }
    end
  end

  context "downloading" do
    setup do
      clean_paths
    end

    should "cp the file" do
      uri = tmp_path.join("foo_source")
      dest = tmp_path.join("foo_dest")

      # Create the source file, then "download" it
      File.open(uri, "w+") { |f| f.write("FOO") }
      File.open(dest, "w+") do |dest_file|
        @downloader.download!(uri, dest_file)
      end

      # Finally, verify the destination file was properly created
      assert File.file?(dest)
      File.open(dest) do |f|
        assert_equal "FOO", f.read
      end
    end
  end

  context "matching a uri" do
    should "return true if the File exists on the file system" do
      File.expects(:exists?).with('foo').returns(true)
      assert Vagrant::Downloaders::File.match?('foo')
    end
  end
end

Version data entries

40 entries across 40 versions & 5 rubygems

Version Path
vagrantup-0.8.9 test/unit/vagrant/downloaders/file_test.rb
vagrantup-0.8.8 test/unit/vagrant/downloaders/file_test.rb
vagrantup-0.8.7 test/unit/vagrant/downloaders/file_test.rb
vagrantup-0.8.6 test/vagrant/downloaders/file_test.rb
vagrantup-0.8.5 test/vagrant/downloaders/file_test.rb
vagrantup-0.8.4 test/vagrant/downloaders/file_test.rb
vagrantup-0.8.3 test/vagrant/downloaders/file_test.rb
vagrantup-0.8.2 test/vagrant/downloaders/file_test.rb
vagrantup-0.8.10 test/unit/vagrant/downloaders/file_test.rb
vagrantup-0.8.1 test/vagrant/downloaders/file_test.rb
vagrantup-0.8.0 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.8 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.7 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.6 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.5 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.4 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.3 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.2 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.1 test/vagrant/downloaders/file_test.rb
vagrantup-0.7.0 test/vagrant/downloaders/file_test.rb