require 'spec_helper'

describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
  before :each do
    @env = EnvironmentHelper.new
  end

  it 'builds unique domain name' do
    @env.random_hostname = true
    dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
    first  = dmn.build_domain_name(@env)
    second = dmn.build_domain_name(@env)
    first.should_not eq(second)
  end

  it 'builds simple domain name' do
    @env.default_prefix = 'pre'
    dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
    dmn.build_domain_name(@env).should eq('pre_')
  end
end

require 'spec_helper'

describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
  before :each do
    @env = EnvironmentHelper.new
  end

  it 'builds unique domain name' do
    @env.random_hostname = true
    dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
    first  = dmn.build_domain_name(@env)
    second = dmn.build_domain_name(@env)
    first.should_not eq(second)
  end

  it 'builds simple domain name' do
    @env.default_prefix = 'pre_'
    dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
    dmn.build_domain_name(@env).should eq('pre_')
  end
end

Update unit test for building simple domain name
Update unit test for building simple domain name

Make the unit test match the new requirement that if a _ postfix is desired
when default_prefix is defined, then it must be added to the default_prefix.