Sha256: 8e3aa440ffea127cce6a88b67fe978e2956b8ad3808405bb1876c58251f36d29

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

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

describe "VagrantPlugins::VagrantPlugins::Cap::ChangeHostName" do
  let(:plugin) { VagrantPlugins::GuestSmartos::Plugin.components.guest_capabilities[:smartos].get(:change_host_name) }
  let(:machine) { double("machine") }
  let(:config) { double("config", smartos: VagrantPlugins::GuestSmartos::Config.new) }
  let(:communicator) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
  let(:old_hostname) { 'oldhostname.olddomain.tld' }
  let(:new_hostname) { 'newhostname.olddomain.tld' }

  before do
    machine.stub(:communicate).and_return(communicator)
    machine.stub(:config).and_return(config)
    communicator.stub_command("hostname | grep '#{old_hostname}'", stdout: old_hostname)
  end

  after do
    communicator.verify_expectations!
  end

  describe ".change_host_name" do
    it "refreshes the hostname service with the hostname command" do
      communicator.expect_command(%Q(pfexec hostname #{new_hostname}))
      plugin.change_host_name(machine, new_hostname)
    end

    it "writes the hostname into /etc/nodename" do
      communicator.expect_command(%Q(pfexec sh -c "echo '#{new_hostname}' > /etc/nodename"))
      plugin.change_host_name(machine, new_hostname)
    end
  end
end

Version data entries

7 entries across 4 versions & 3 rubygems

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