Sha256: 968f324de4b06966c7a2eac6991cfd5a0afa1f569b331d8ee9ca20a0673bc5ab

Contents?: true

Size: 1.67 KB

Versions: 2

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

require 'vagrant/ui'
require Vagrant.source_root.join('plugins/communicators/ssh/communicator')

require 'vocker/docker_installer'

describe VagrantPlugins::Vocker::DockerInstaller do
  verify_contract(:docker_installer)

  fake(:guest)
  fake(:ui) { Vagrant::UI::Interface }
  let(:machine) { fake(:machine, guest: guest, ui: ui) }
  let(:version) { '0.6.4' }

  subject { described_class.new(machine, version) }

  it 'skips docker installation if guest is not capable' do
    stub(guest).capability?(:docker_installed) { false }

    subject.ensure_installed

    expect(guest).to_not have_received.capability(:docker_installed)
    expect(guest).to_not have_received.capability(:docker_install)
  end

  it 'skips docker installation if already installed' do
    stub(guest).capability(:docker_installed) { true }

    subject.ensure_installed

    expect(guest).to have_received.capability(:docker_installed)
    expect(guest).to_not have_received.capability(:docker_install)
  end

  it 'installs docker if not installed' do
    # XXX: This is kinda hacky I believe
    stub(guest).capability(:docker_installed) {
      stub(guest).capability(:docker_installed) { true }
      false
    }

    subject.ensure_installed

    expect(guest).to have_received.capability(:docker_installed)
    expect(guest).to have_received.capability(:docker_install, version)
    expect(guest).to have_received.capability(:docker_configure_auto_start)
  end

  it 'errors out if docker could not be installed' do
    stub(guest).capability(:docker_installed) { false }

    expect {
      subject.ensure_installed
    }.to raise_error(VagrantPlugins::Vocker::Errors::DockerInstallFailed)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vocker-0.4.1 spec/unit/docker_installer_spec.rb
vocker-0.4.0 spec/unit/docker_installer_spec.rb