values_spec.rb 801 B

1234567891011121314151617181920212223242526272829
  1. require 'spec_helper_acceptance'
  2. describe 'values function', :if => Puppet::Util::Package.versioncmp(Puppet.version, '5.5.0') < 0 do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $arg = {
  6. 'a' => 1,
  7. 'b' => 2,
  8. 'c' => 3,
  9. }
  10. $output = values($arg)
  11. notice(inline_template('<%= @output.sort.inspect %>'))
  12. DOC
  13. it 'returns an array of values' do
  14. expect(apply_manifest(pp1, :catch_failures => true).stdout).to match(%r{\[1, 2, 3\]})
  15. end
  16. end
  17. describe 'failure' do
  18. pp2 = <<-DOC
  19. $arg = "foo"
  20. $output = values($arg)
  21. notice(inline_template('<%= @output.inspect %>'))
  22. DOC
  23. it 'handles non-hash arguments' do
  24. expect(apply_manifest(pp2, :expect_failures => true).stderr).to match(%r{Requires hash})
  25. end
  26. end
  27. end