37
|
1 #! /usr/bin/env ruby -S rspec
|
|
2 require 'spec_helper_acceptance'
|
|
3
|
|
4 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
|
|
12 describe 'success' do
|
|
13 it 'members arrays' do
|
|
14 pp = <<-EOS
|
|
15 $a = ['aaa','bbb','ccc']
|
|
16 $b = 'ccc'
|
|
17 $c = true
|
|
18 $o = member($a,$b)
|
|
19 if $o == $c {
|
|
20 notify { 'output correct': }
|
|
21 }
|
|
22 EOS
|
|
23
|
|
24 apply_manifest(pp, :catch_failures => true) do |r|
|
|
25 expect(r.stdout).to match(/Notice: output correct/)
|
|
26 end
|
|
27 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
|
|
48 it 'members arrays without members'
|
|
49 end
|
|
50
|
|
51 describe 'failure' do
|
|
52 it 'handles improper argument counts'
|
|
53 end
|
|
54 end
|