]> gitweb.fluxo.info Git - puppet-stdlib.git/commitdiff
MODULES-1413 Ability to for future parser to use member with FixNum types
authorTravis Fields <travis@puppetlabs.com>
Thu, 30 Oct 2014 05:02:13 +0000 (22:02 -0700)
committerTravis Fields <travis@puppetlabs.com>
Tue, 4 Nov 2014 22:33:34 +0000 (14:33 -0800)
lib/puppet/parser/functions/member.rb
spec/acceptance/member_spec.rb

index 43d76affd9a5ff873fe3049bf8685c36a9330870..11a1d2495725a8c5a8c624dd5a10a3cffa055f52 100644 (file)
@@ -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)
 
index b467dbbe9c2b7b3aa2fcb5dcc16ea5843317d945..fe75a0782569b53e0312021b9a4cdab3d96eca15 100755 (executable)
@@ -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