Skip to content

Commit

Permalink
Merge pull request #350 from cyberious/modules1413
Browse files Browse the repository at this point in the history
MODULES-1413 Add ability for member to take numeric objects
  • Loading branch information
Morgan Haskel committed Nov 4, 2014
2 parents 2f3d426 + f19aea5 commit 03f0ecd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/puppet/parser/functions/member.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ module Puppet::Parser::Functions

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)

Expand Down
28 changes: 28 additions & 0 deletions spec/acceptance/member_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,8 +25,29 @@
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
Expand Down

0 comments on commit 03f0ecd

Please sign in to comment.