reject_spec.rb 1.2 KB

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