Sha256: ad413c47697420de563f736f5c6aedc92f64d1f18e2416b1e22c3721c3c19fd8

Contents?: true

Size: 1.69 KB

Versions: 1

Compression:

Stored size: 1.69 KB

Contents

shared_examples "provider/provisioner/shell" do |provider, options|
  if !options[:box]
    raise ArgumentError,
      "box_basic option must be specified for provider: #{provider}"
  end

  include_context "acceptance"

  before do
    environment.skeleton("provisioner_shell")

    vagrantfile = environment.workdir.join('Vagrantfile')
    # TODO: Can we just shell out to something?
    new_vagrantfile = "Vagrant.require_plugin('docker-provider')\n#{vagrantfile.read}"
    vagrantfile.open('w') { |f| f.puts(new_vagrantfile) }

    assert_execute("vagrant", "box", "add", "box", options[:box])
    assert_execute("vagrant", "up", "--provider=#{provider}")
  end

  after do
    assert_execute("vagrant", "destroy", "--force")
  end

  it "provisions with the shell script" do
    status("Test: inline script")
    result = execute("vagrant", "ssh", "-c", "cat /foo")
    expect(result).to exit_with(0)
    expect(result.stdout).to match(/foo\n$/)

    status("Test: script from path")
    result = execute("vagrant", "ssh", "-c", "cat /vagrant-path")
    expect(result).to exit_with(0)
    expect(result.stdout).to match(/bar\n$/)

    status("Test: script with args")
    result = execute("vagrant", "ssh", "-c", "cat /vagrant-args")
    expect(result).to exit_with(0)
    expect(result.stdout).to match(/hello\ntwo words\n$/)

    status("Test: privileged scripts")
    result = execute("vagrant", "ssh", "-c", "cat /tmp/vagrant-user-root")
    expect(result).to exit_with(0)
    expect(result.stdout).to match(/root$/)

    status("Test: non-privileged scripts")
    result = execute("vagrant", "ssh", "-c", "cat /tmp/vagrant-user")
    expect(result).to exit_with(0)
    expect(result.stdout).to_not match(/root$/)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
docker-provider-0.1.0 spec/acceptance/provisioner/shell_spec.rb