member_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. require 'spec_helper_acceptance'
  2. describe 'member function' do
  3. shared_examples 'item found' do
  4. it 'outputs correctly' do
  5. apply_manifest(pp, :catch_failures => true) do |r|
  6. expect(r.stdout).to match(%r{Notice: output correct})
  7. end
  8. end
  9. end
  10. describe 'success' do
  11. pp1 = <<-DOC
  12. $a = ['aaa','bbb','ccc']
  13. $b = 'ccc'
  14. $c = true
  15. $o = member($a,$b)
  16. if $o == $c {
  17. notify { 'output correct': }
  18. }
  19. DOC
  20. it 'members arrays' do
  21. apply_manifest(pp1, :catch_failures => true) do |r|
  22. expect(r.stdout).to match(%r{Notice: output correct})
  23. end
  24. end
  25. describe 'members array of integers' do
  26. let(:pp) do
  27. <<-DOC
  28. if member( [1,2,3,4], 4 ){
  29. notify { 'output correct': }
  30. }
  31. DOC
  32. end
  33. it_behaves_like 'item found' do
  34. end
  35. end
  36. describe 'members of mixed array' do
  37. let(:pp) do
  38. <<-DOC
  39. if member( ['a','4',3], 'a' ){
  40. notify { 'output correct': }
  41. }
  42. DOC
  43. end
  44. it_behaves_like 'item found' do
  45. end
  46. end
  47. it 'members arrays without members'
  48. end
  49. describe 'failure' do
  50. it 'handles improper argument counts'
  51. end
  52. end