Sha256: f52aaff3063f7ab7392d0e4dcee29511d2519ca9b7d389a2f640ddd9df215b49

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

# encoding: UTF-8
# Copyright (c) 2015 VMware, Inc. All Rights Reserved.

require File.expand_path("../../../../../base", __FILE__)

describe "VagrantPlugins::GuestPhoton::Cap::ChangeHostName" do
  let(:described_class) do
    VagrantPlugins::GuestPhoton::Plugin.components.guest_capabilities[:photon].get(:change_host_name)
  end
  let(:machine) { double("machine") }
  let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }

  before do
    allow(machine).to receive(:communicate).and_return(communicator)
  end

  after do
    communicator.verify_expectations!
  end

  it 'should change hostname when hostname is differ from current' do
    hostname = 'vagrant-photon'
    expect(communicator).to receive(:test).with("sudo hostname --fqdn | grep 'vagrant-photon'")
    communicator.should_receive(:sudo).with("hostname #{hostname.split('.')[0]}")
    described_class.change_host_name(machine, hostname)
  end

  it 'should not change hostname when hostname equals current' do
    hostname = 'vagrant-photon'
    communicator.stub(:test).and_return(true)
    communicator.should_not_receive(:sudo)
    described_class.change_host_name(machine, hostname)
  end
end

Version data entries

6 entries across 3 versions & 2 rubygems

Version Path
vagrant-unbundled-1.8.1.2 test/unit/plugins/guests/photon/cap/change_host_name_test.rb
vagrant-unbundled-1.8.1.1 test/unit/plugins/guests/photon/cap/change_host_name_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-1cf2a8db4ccb/test/unit/plugins/guests/photon/cap/change_host_name_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-272fb27e0536/test/unit/plugins/guests/photon/cap/change_host_name_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-309e896975d1/test/unit/plugins/guests/photon/cap/change_host_name_test.rb
vagrant-cloudstack-1.1.0 vendor/bundle/bundler/gems/vagrant-b421af58e8b3/test/unit/plugins/guests/photon/cap/change_host_name_test.rb