diff options
author | Morgan Haskel <morgan@puppetlabs.com> | 2014-11-04 15:29:25 -0800 |
---|---|---|
committer | Morgan Haskel <morgan@puppetlabs.com> | 2014-11-04 15:29:25 -0800 |
commit | 03f0ecd1286196c1d63342fe10f079e588cd2e58 (patch) | |
tree | b5106ec0cd39922ef2ec6ba78f151a9994008315 | |
parent | 2f3d426ba7ad2c3055e4774aa71c77c65e866c43 (diff) | |
parent | f19aea5a75998da95617fadce7a50aee65022d3b (diff) |
Merge pull request #350 from cyberious/modules1413
MODULES-1413 Add ability for member to take numeric objects
-rw-r--r-- | lib/puppet/parser/functions/member.rb | 3 | ||||
-rwxr-xr-x | spec/acceptance/member_spec.rb | 28 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions/member.rb b/lib/puppet/parser/functions/member.rb index 43d76af..11a1d24 100644 --- a/lib/puppet/parser/functions/member.rb +++ b/lib/puppet/parser/functions/member.rb @@ -32,8 +32,9 @@ Would return: false item = arguments[1] + raise(Puppet::ParseError, 'member(): You must provide item ' + - 'to search for within array given') if item.empty? + 'to search for within array given') if item.respond_to?('empty?') && item.empty? result = array.include?(item) diff --git a/spec/acceptance/member_spec.rb b/spec/acceptance/member_spec.rb index b467dbb..fe75a07 100755 --- a/spec/acceptance/member_spec.rb +++ b/spec/acceptance/member_spec.rb @@ -2,6 +2,13 @@ require 'spec_helper_acceptance' describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do + shared_examples 'item found' do + it 'should output correctly' do + apply_manifest(pp, :catch_failures => true) do |r| + expect(r.stdout).to match(/Notice: output correct/) + end + end + end describe 'success' do it 'members arrays' do pp = <<-EOS @@ -18,8 +25,29 @@ describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('oper expect(r.stdout).to match(/Notice: output correct/) end end + describe 'members array of integers' do + it_should_behave_like 'item found' do + let(:pp) { <<-EOS + if member( [1,2,3,4], 4 ){ + notify { 'output correct': } + } + EOS + } + end + end + describe 'members of mixed array' do + it_should_behave_like 'item found' do + let(:pp) { <<-EOS + if member( ['a','4',3], 'a' ){ + notify { 'output correct': } +} + EOS + } + end + end it 'members arrays without members' end + describe 'failure' do it 'handles improper argument counts' end |