Sha256: 015951a445935746f44363d020a32471bd78489917fc62c596f7859f9158a6ea

Contents?: true

Size: 1.34 KB

Versions: 92

Compression:

Stored size: 1.34 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

require 'puppet/parameter/package_options'

describe Puppet::Parameter::PackageOptions do
  let (:resource) { mock('resource') }
  let (:param)    { described_class.new(:resource => resource) }
  let (:arg)      { '/S' }
  let (:key)      { 'INSTALLDIR' }
  let (:value)    { 'C:/mydir' }

  context '#munge' do
    # The parser automatically converts single element arrays to just
    # a single element, why it does this is beyond me. See 46252b5bb8
    it 'should accept a string' do
      param.munge(arg).should == [arg]
    end

    it 'should accept a hash' do
      param.munge({key => value}).should == [{key => value}]
    end

    it 'should accept an array of strings and hashes' do
      munged = param.munge([arg, {key => value}, '/NCRC', {'CONF' => 'C:\datadir'}])
      munged.should == [arg, {key => value}, '/NCRC', {'CONF' => 'C:\datadir'}]
    end

    it 'should quote strings' do
      param.munge('arg one').should == ["\"arg one\""]
    end

    it 'should quote hash pairs' do
      munged = param.munge({'INSTALL DIR' => 'C:\Program Files'})
      munged.should == [{"\"INSTALL DIR\"" => "\"C:\\Program Files\""}]
    end

    it 'should reject symbols' do
      expect {
        param.munge([:symbol])
      }.to raise_error(Puppet::Error, /Expected either a string or hash of options/)
    end
  end
end

Version data entries

92 entries across 92 versions & 2 rubygems

Version Path
puppet-3.8.7 spec/unit/parameter/package_options_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.6 spec/unit/parameter/package_options_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.5 spec/unit/parameter/package_options_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.4 spec/unit/parameter/package_options_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.3 spec/unit/parameter/package_options_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.2 spec/unit/parameter/package_options_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/parameter/package_options_spec.rb
puppet-3.8.1 spec/unit/parameter/package_options_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/parameter/package_options_spec.rb