Sha256: ea2965976607423922f32defbf3a8314b4f271f3b2ef9c6e121deb3ada61c05a

Contents?: true

Size: 1.29 KB

Versions: 14

Compression:

Stored size: 1.29 KB

Contents

require_relative "../../../../base"
require_relative "../../../../../../plugins/guests/smartos/config"

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

14 entries across 14 versions & 3 rubygems

Version Path
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-unbundled-1.9.5.1 test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-unbundled-1.9.1.1 test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-unbundled-1.8.5.2 test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-unbundled-1.8.5.1 test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-unbundled-1.8.4.2 test/unit/plugins/guests/smartos/cap/change_host_name_test.rb
vagrant-unbundled-1.8.4.1 test/unit/plugins/guests/smartos/cap/change_host_name_test.rb