count_spec.rb 676 B

123456789101112131415161718192021222324252627
  1. require 'spec_helper_acceptance'
  2. describe 'count function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $input = [1,2,3,4]
  6. $output = count($input)
  7. notify { "$output": }
  8. DOC
  9. it 'counts elements in an array' do
  10. apply_manifest(pp1, :catch_failures => true) do |r|
  11. expect(r.stdout).to match(%r{Notice: 4})
  12. end
  13. end
  14. pp2 = <<-DOC
  15. $input = [1,1,1,2]
  16. $output = count($input, 1)
  17. notify { "$output": }
  18. DOC
  19. it 'counts elements in an array that match a second argument' do
  20. apply_manifest(pp2, :catch_failures => true) do |r|
  21. expect(r.stdout).to match(%r{Notice: 3})
  22. end
  23. end
  24. end
  25. end