Sha256: 406de09314bb6f0ee2e6247671d0d4eae240f490e28f4bf133d41c7bbb77c3c5

Contents?: true

Size: 1.27 KB

Versions: 7

Compression:

Stored size: 1.27 KB

Contents

#! /usr/bin/env ruby -S rspec

require 'spec_helper'

describe Puppet::Parser::Functions.function(:validate_array) do
  let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
  describe 'when calling validate_array from puppet' do

    %w{ true false }.each do |the_string|
      it "should not compile when #{the_string} is a string" do
        Puppet[:code] = "validate_array('#{the_string}')"
        expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/)
      end

      it "should not compile when #{the_string} is a bare word" do
        Puppet[:code] = "validate_array(#{the_string})"
        expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/)
      end
    end

    it "should compile when multiple array arguments are passed" do
      Puppet[:code] = <<-'ENDofPUPPETcode'
        $foo = [ ]
        $bar = [ 'one', 'two' ]
        validate_array($foo, $bar)
      ENDofPUPPETcode
      scope.compiler.compile
    end

    it "should not compile when an undef variable is passed" do
      Puppet[:code] = <<-'ENDofPUPPETcode'
        $foo = undef
        validate_array($foo)
      ENDofPUPPETcode
      expect { scope.compiler.compile }.should raise_error(Puppet::ParseError, /is not an Array/)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
service_kiosk-0.5.6 provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb
service_kiosk-0.5.5 provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb
service_kiosk-0.5.4 provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb
service_kiosk-0.5.3 provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb
service_kiosk-0.5.2 provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb
service_kiosk-0.5.1 provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb
service_kiosk-0.5.0 provision/modules/stdlib/spec/unit/puppet/parser/functions/validate_array_spec.rb