validate_hash_spec.rb 882 B

123456789101112131415161718192021222324252627282930313233343536
  1. require 'spec_helper_acceptance'
  2. describe 'validate_hash function' do
  3. describe 'success' do
  4. pp1 = <<-DOC
  5. $one = { 'a' => 1 }
  6. validate_hash($one)
  7. DOC
  8. it 'validates a single argument' do
  9. apply_manifest(pp1, :catch_failures => true)
  10. end
  11. pp2 = <<-DOC
  12. $one = { 'a' => 1 }
  13. $two = { 'b' => 2 }
  14. validate_hash($one,$two)
  15. DOC
  16. it 'validates an multiple arguments' do
  17. apply_manifest(pp2, :catch_failures => true)
  18. end
  19. [
  20. %{validate_hash('{ "not" => "hash" }')},
  21. %{validate_hash('string')},
  22. %{validate_hash(["array"])},
  23. %{validate_hash(undef)},
  24. ].each do |pp3|
  25. it "rejects #{pp3.inspect}" do
  26. expect(apply_manifest(pp3, :expect_failures => true).stderr).to match(%r{})
  27. end
  28. end
  29. end
  30. describe 'failure' do
  31. it 'handles improper number of arguments'
  32. end
  33. end