Sha256: d959dbdd93b35d65e2aa853338bf4c4e45349a555ab4969e93acf9fb4ad93c56

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

require File.expand_path("../base", __FILE__)
require "support/shared/command_examples"

describe "vagrant ssh" do
  include_context "acceptance"
  it_behaves_like "a command that requires a Vagrantfile", ["vagrant", "ssh"]
  it_behaves_like "a command that requires a virtual machine", ["vagrant", "ssh"]

  it "is able to SSH into a running virtual machine" do
    require_box("default")

    assert_execute("vagrant", "box", "add", "base", box_path("default"))
    assert_execute("vagrant", "init")
    assert_execute("vagrant", "up")

    outputted = false
    result = assert_execute("vagrant", "ssh") do |io_type, data|
      if io_type == :stdin and !outputted
        data.puts("echo hello")
        data.puts("exit")
        outputted = true
      end
    end

    result.stdout.chomp.should eql("hello"), "Vagrant should bring up a VM to be able to SSH into."
  end

  it "is able to execute a single command via the command line" do
    require_box("default")

    assert_execute("vagrant", "box", "add", "base", box_path("default"))
    assert_execute("vagrant", "init")
    assert_execute("vagrant", "up")

    result = assert_execute("vagrant", "ssh", "-c", "echo foo")
    result.stdout.should == "foo\n"
  end

  # TODO:
  # SSH should fail if the VM is not running
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
vagrantup-0.8.9 test/acceptance/ssh_test.rb
vagrantup-0.8.8 test/acceptance/ssh_test.rb
vagrantup-0.8.10 test/acceptance/ssh_test.rb
vagrant-0.8.10 test/acceptance/ssh_test.rb
vagrant-0.8.8 test/acceptance/ssh_test.rb