Sha256: 4af909f9e1ce3fd65d77133ed6a69e9b1fdfd8b0ac961a07b9a42b14c8f92ae9

Contents?: true

Size: 1.9 KB

Versions: 2

Compression:

Stored size: 1.9 KB

Contents

require 'spec_helper'

describe VagrantWindows::Provisioners::ChefCommandBuilder, :unit => true do

  before(:each) do
    @winrm_config = stub()
    @winrm_config.stubs(:username).returns('vagrant')
    @winrm_config.stubs(:password).returns('secret')

    @windows_machine = stub()
    @windows_machine.stubs(:winrm_config).returns(@winrm_config)

    @chef_config = stub()
    @chef_config.stubs(:provisioning_path).returns('/tmp/vagrant-chef-1')
    @chef_config.stubs(:arguments).returns(nil)
    @chef_config.stubs(:binary_env).returns(nil)
    @chef_config.stubs(:binary_path).returns(nil)

    @chef_cmd_builder = VagrantWindows::Provisioners::ChefCommandBuilder.new(
      @windows_machine, @chef_config, :client)
  end

  describe 'initialize' do
    it 'should raise when chef type is not client or solo' do
      expect { VagrantWindows::Provisioners::ChefCommandBuilder.new(@windows_machine, @chef_config, :zero) }.to raise_error
    end
  end

  describe 'provisioning_path' do
    it 'should be windows friendly' do
      @chef_cmd_builder.provisioning_path('script.ps1').should eql 'c:\tmp\vagrant-chef-1\script.ps1'
    end
  end

  describe 'chef_arguments' do
    it 'should include paths to client.rb and dna.json' do
      expected = '-c c:\tmp\vagrant-chef-1\client.rb -j c:\tmp\vagrant-chef-1\dna.json'
      @chef_cmd_builder.chef_arguments().should eql expected
    end

    it 'should include Chef arguments if specified' do
      @chef_config.stubs(:arguments).returns('-l DEBUG')
      expected = '-c c:\tmp\vagrant-chef-1\client.rb -j c:\tmp\vagrant-chef-1\dna.json -l DEBUG'
      @chef_cmd_builder.chef_arguments().should eql expected
    end
  end

  describe 'run chef command' do
    it "should include chef-client cmd line" do
      expect(@chef_cmd_builder.run_chef_command()).to include(
        'chef-client -c c:\\tmp\\vagrant-chef-1\\client.rb -j c:\\tmp\\vagrant-chef-1\\dna.json')
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-windows-1.7.0.pre.2 spec/vagrant-windows/chef_command_builder_spec.rb
vagrant-windows-1.7.0.pre.1 spec/vagrant-windows/chef_command_builder_spec.rb