capitalize_spec.rb 864 B

123456789101112131415161718192021222324252627282930
  1. require 'spec_helper_acceptance'
  2. describe 'capitalize function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $input = 'this is a string'
  6. $output = capitalize($input)
  7. notify { $output: }
  8. DOC
  9. it 'capitalizes the first letter of a string' do
  10. apply_manifest(pp1, :catch_failures => true) do |r|
  11. expect(r.stdout).to match(%r{Notice: This is a string})
  12. end
  13. end
  14. pp2 = <<-DOC
  15. $input = ['this', 'is', 'a', 'string']
  16. $output = capitalize($input)
  17. notify { $output: }
  18. DOC
  19. regex_array = [%r{Notice: This}, %r{Notice: Is}, %r{Notice: A}, %r{Notice: String}]
  20. it 'capitalizes the first letter of an array of strings' do
  21. apply_manifest(pp2, :catch_failures => true) do |r|
  22. regex_array.each do |i|
  23. expect(r.stdout).to match(i)
  24. end
  25. end
  26. end
  27. end
  28. end