Sha256: a91225c1d9d23d04cb0ebe40c9408524258c2eeb5d759269bb063cd866eef496

Contents?: true

Size: 1.39 KB

Versions: 10

Compression:

Stored size: 1.39 KB

Contents

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

class CommandsSSHConfigTest < Test::Unit::TestCase
  setup do
    @klass = Vagrant::Commands::SSHConfig

    @persisted_vm = mock("persisted_vm")
    @persisted_vm.stubs(:execute!)

    @env = mock_environment
    @env.stubs(:require_persisted_vm)
    @env.stubs(:vm).returns(@persisted_vm)

    @instance = @klass.new(@env)
  end

  context "executing" do
    setup do
      @ssh = mock("ssh")
      @ssh.stubs(:port).returns(2197)
      @env.stubs(:ssh).returns(@ssh)
      @env.stubs(:require_root_path)

      @instance.stubs(:puts)

      @data = {
        :host_key => "vagrant",
        :ssh_user => @env.config.ssh.username,
        :ssh_port => @env.ssh.port,
        :private_key_path => @env.config.ssh.private_key_path
      }
    end

    should "require root path" do
      @env.expects(:require_root_path).once
      @instance.execute
    end

    should "output rendered template" do
      result = mock("result")
      Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data).returns(result)

      @instance.expects(:puts).with(result).once
      @instance.execute
    end

    should "render with the given host name if given" do
      host = "foo"
      @data[:host_key] = host
      Vagrant::Util::TemplateRenderer.expects(:render).with("ssh_config", @data)
      @instance.execute(["--host", host])
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
vagrantup-0.3.4 test/vagrant/commands/ssh_config_test.rb
vagrantup-0.3.3 test/vagrant/commands/ssh_config_test.rb
vagrantup-0.3.2 test/vagrant/commands/ssh_config_test.rb
vagrantup-0.3.1 test/vagrant/commands/ssh_config_test.rb
vagrantup-0.3.0 test/vagrant/commands/ssh_config_test.rb
vagrant-0.3.4 test/vagrant/commands/ssh_config_test.rb
vagrant-0.3.3 test/vagrant/commands/ssh_config_test.rb
vagrant-0.3.2 test/vagrant/commands/ssh_config_test.rb
vagrant-0.3.1 test/vagrant/commands/ssh_config_test.rb
vagrant-0.3.0 test/vagrant/commands/ssh_config_test.rb