Sha256: 4157eab50cf24dbe70b530e5cd0f1f98f7b8af54b40149ebc1bd93b2cc41367e

Contents?: true

Size: 1.67 KB

Versions: 38

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

describe Beaker::VagrantCustom do
  let( :options ) { make_opts.merge({ :hosts_file => 'sample.cfg', 'logger' => double().as_null_object }) }
  let( :vagrant ) { Beaker::VagrantCustom.new( @hosts, options ) }

  let(:test_dir) { 'tmp/tests' }
  let(:custom_vagrant_file_path)  { File.expand_path(test_dir + '/CustomVagrantfile')   }

  before :each do
    @hosts = make_hosts()
  end

  it "uses the vagrant_custom provider for provisioning" do
    @hosts.each do |host|
      host_prev_name = host['user']
      expect( vagrant ).to receive( :set_ssh_config ).with( host, 'vagrant' ).once
      expect( vagrant ).to receive( :copy_ssh_to_root ).with( host, options ).once
      expect( vagrant ).to receive( :set_ssh_config ).with( host, host_prev_name ).once
    end
    expect( vagrant ).to receive( :hack_etc_hosts ).with( @hosts, options ).once
    FakeFS.activate!
    expect( vagrant ).to receive( :vagrant_cmd ).with( "up" ).once
    vagrant.provision
  end

  context 'takes vagrant configuration from existing file' do
    it 'writes the vagrant file to the correct location' do
      options.merge!({ :vagrantfile_path => custom_vagrant_file_path })

      create_files([custom_vagrant_file_path])

      vagrant_file_contents = <<-EOF
FOO
      EOF
      File.open(custom_vagrant_file_path, 'w') { |file| file.write(vagrant_file_contents) }

      vagrant_copy_location = "#{test_dir}/NewVagrantLocation"
      vagrant.instance_variable_set(:@vagrant_file, vagrant_copy_location)
      vagrant.make_vfile(@hosts, options)
      vagrant_copy_file = File.open(vagrant_copy_location, 'r')
      expect(vagrant_copy_file.read).to be === vagrant_file_contents
    end

  end
end

Version data entries

38 entries across 38 versions & 2 rubygems

Version Path
beaker-vagrant-0.6.7 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.6.6 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.6.5 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.6.4 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.6.3 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.6.2 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.6.1 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.6.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.5.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.4.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.3.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.2.1 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.2.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.1.1 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-vagrant-0.1.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-3.20.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-3.19.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-3.18.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-3.17.0 spec/beaker/hypervisor/vagrant_custom_spec.rb
beaker-3.16.0 spec/beaker/hypervisor/vagrant_custom_spec.rb