prefix_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. require 'spec_helper_acceptance'
  2. describe 'prefix function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $o = prefix(['a','b','c'],'p')
  6. notice(inline_template('prefix is <%= @o.inspect %>'))
  7. DOC
  8. it 'prefixes array of values' do
  9. apply_manifest(pp1, :catch_failures => true) do |r|
  10. expect(r.stdout).to match(%r{prefix is \["pa", "pb", "pc"\]})
  11. end
  12. end
  13. pp2 = <<-DOC
  14. $o = prefix([],'p')
  15. notice(inline_template('prefix is <%= @o.inspect %>'))
  16. DOC
  17. it 'prefixs with empty array' do
  18. apply_manifest(pp2, :catch_failures => true) do |r|
  19. expect(r.stdout).to match(%r{prefix is \[\]})
  20. end
  21. end
  22. pp3 = <<-DOC
  23. $o = prefix(['a','b','c'], undef)
  24. notice(inline_template('prefix is <%= @o.inspect %>'))
  25. DOC
  26. it 'prefixs array of values with undef' do
  27. apply_manifest(pp3, :catch_failures => true) do |r|
  28. expect(r.stdout).to match(%r{prefix is \["a", "b", "c"\]})
  29. end
  30. end
  31. end
  32. describe 'failure' do
  33. it 'fails with no arguments'
  34. it 'fails when first argument is not array'
  35. it 'fails when second argument is not string'
  36. end
  37. end