Skip to content

Commit 03f0ecd

Browse files
author
Morgan Haskel
committed
Merge pull request #350 from cyberious/modules1413
MODULES-1413 Add ability for member to take numeric objects
2 parents 2f3d426 + f19aea5 commit 03f0ecd

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

lib/puppet/parser/functions/member.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ module Puppet::Parser::Functions
3232

3333
item = arguments[1]
3434

35+
3536
raise(Puppet::ParseError, 'member(): You must provide item ' +
36-
'to search for within array given') if item.empty?
37+
'to search for within array given') if item.respond_to?('empty?') && item.empty?
3738

3839
result = array.include?(item)
3940

spec/acceptance/member_spec.rb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
require 'spec_helper_acceptance'
33

44
describe 'member function', :unless => UNSUPPORTED_PLATFORMS.include?(fact('operatingsystem')) do
5+
shared_examples 'item found' do
6+
it 'should output correctly' do
7+
apply_manifest(pp, :catch_failures => true) do |r|
8+
expect(r.stdout).to match(/Notice: output correct/)
9+
end
10+
end
11+
end
512
describe 'success' do
613
it 'members arrays' do
714
pp = <<-EOS
@@ -18,8 +25,29 @@
1825
expect(r.stdout).to match(/Notice: output correct/)
1926
end
2027
end
28+
describe 'members array of integers' do
29+
it_should_behave_like 'item found' do
30+
let(:pp) { <<-EOS
31+
if member( [1,2,3,4], 4 ){
32+
notify { 'output correct': }
33+
}
34+
EOS
35+
}
36+
end
37+
end
38+
describe 'members of mixed array' do
39+
it_should_behave_like 'item found' do
40+
let(:pp) { <<-EOS
41+
if member( ['a','4',3], 'a' ){
42+
notify { 'output correct': }
43+
}
44+
EOS
45+
}
46+
end
47+
end
2148
it 'members arrays without members'
2249
end
50+
2351
describe 'failure' do
2452
it 'handles improper argument counts'
2553
end

0 commit comments

Comments
 (0)