Sha256: 2f46df1436bf3e8e05bcbdfb4c0fb309ec2704b09e6a0057565ee642b330d865

Contents?: true

Size: 1.65 KB

Versions: 41

Compression:

Stored size: 1.65 KB

Contents

require 'spec_helper'

require 'pe_build/provisioner/pe_bootstrap'

describe PEBuild::Provisioner::PEBootstrap::AnswersFile do
  include_context 'vagrant-unit'

  let(:test_env) do
    test_env = isolated_environment
    test_env.vagrantfile <<-EOF
Vagrant.configure('2') do |config|
  config.vm.define :test
end
EOF

    test_env
  end
  let(:env)              { test_env.create_vagrant_env }
  let(:machine)          { env.machine(:test, :dummy) }
  let(:bootstrap_config) { PEBuild::Config::PEBootstrap.new }

  # Mock the communicator to prevent SSH commands from being executed.
  let(:communicator)     { double('communicator') }
  # Mock the guest operating system.
  let(:guest)            { double('guest') }

  before (:each) do
    machine.stub(:guest => guest)
    machine.stub(:communicator => communicator)
  end

  after(:each) { test_env.close }

  subject do
    provisioner = described_class.new(machine, bootstrap_config, env.root_path.join(PEBuild::WORK_DIR))
    provisioner.stub(:template_data) { "original template" }

    provisioner
  end


  context 'when answer_extras is not configured' do
    before(:each) do
      bootstrap_config.version = '3.8.2'

      bootstrap_config.finalize!
    end

    it 'does not modify the template' do
      expect(subject.render_answers).to eq("original template")
    end
  end

  context 'when answer_extras is configured' do
    before(:each) do
      bootstrap_config.version = '3.8.2'
      bootstrap_config.answer_extras = ['q_foo=bar', 'q_baz=bim']

      bootstrap_config.finalize!
    end

    it 'appends answers to the template' do
      expect(subject.render_answers.lines.last).to eq("q_baz=bim\n")
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
vagrant-pe_build-0.19.2 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.19.1 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.19.0 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.18.2 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.18.1 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.18.0 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.14 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.13 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.12 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.11 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.10 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.9 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.8 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.7 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.6 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.5 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.4 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.3 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.2 spec/unit/provisioner/pe_bootstrap_answers_spec.rb
vagrant-pe_build-0.17.1 spec/unit/provisioner/pe_bootstrap_answers_spec.rb