Sha256: 8108a793ca17fceac4daaf17417c06089a6e738e532ba6d64f0706c503b9adc4

Contents?: true

Size: 1010 Bytes

Versions: 18

Compression:

Stored size: 1010 Bytes

Contents

# encoding: UTF-8
# Copyright (c) 2018 António Meireles. All Rights Reserved.

require 'vagrant-guests-ClearLinux/cap/change_host_name'
require 'spec_helper'

describe VagrantPlugins::GuestClearLinux::Cap::ChangeHostName do
  include_context 'machine'

  it 'should change hostname when hostname is differ from current' do
    hostname = 'vagrant-clearlinux'
    expect(communicate).to receive(:test).with("hostnamectl --static | grep 'vagrant-clearlinux'")
    communicate.should_receive(:sudo).with("rm /etc/machine-id")
    communicate.should_receive(:sudo).with("systemd-machine-id-setup")
    communicate.should_receive(:sudo).with("hostnamectl set-hostname #{hostname.split('.')[0]}")
    described_class.change_host_name(machine, hostname)
  end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
vagrant-guests-clearlinux-1.2.4 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.2.3 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.2.2 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.1.3 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.1.2 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.1.1 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.1.0 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.16 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.14 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.13 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.12 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.11 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.10 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.9 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.8 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.7 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.6 spec/cap/change_host_name_spec.rb
vagrant-guests-clearlinux-1.0.5 spec/cap/change_host_name_spec.rb