suffix_spec.rb 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. require 'spec_helper_acceptance'
  2. describe 'suffix function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $o = suffix(['a','b','c'],'p')
  6. notice(inline_template('suffix is <%= @o.inspect %>'))
  7. DOC
  8. it 'suffixes array of values' do
  9. apply_manifest(pp1, :catch_failures => true) do |r|
  10. expect(r.stdout).to match(%r{suffix is \["ap", "bp", "cp"\]})
  11. end
  12. end
  13. pp2 = <<-DOC
  14. $o = suffix([],'p')
  15. notice(inline_template('suffix is <%= @o.inspect %>'))
  16. DOC
  17. it 'suffixs with empty array' do
  18. apply_manifest(pp2, :catch_failures => true) do |r|
  19. expect(r.stdout).to match(%r{suffix is \[\]})
  20. end
  21. end
  22. pp3 = <<-DOC
  23. $o = suffix(['a','b','c'], undef)
  24. notice(inline_template('suffix is <%= @o.inspect %>'))
  25. DOC
  26. it 'suffixs array of values with undef' do
  27. apply_manifest(pp3, :catch_failures => true) do |r|
  28. expect(r.stdout).to match(%r{suffix 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