validate_hash_spec.rb 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'spec_helper'
  2. describe 'validate_hash' do
  3. describe 'signature validation' do
  4. it { is_expected.not_to eq(nil) }
  5. it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
  6. describe 'check for deprecation warning' do
  7. after(:each) do
  8. ENV.delete('STDLIB_LOG_DEPRECATIONS')
  9. end
  10. # Checking for deprecation warning
  11. it 'displays a single deprecation' do
  12. ENV['STDLIB_LOG_DEPRECATIONS'] = 'true'
  13. scope.expects(:warning).with(includes('This method is deprecated'))
  14. is_expected.to run.with_params('key' => 'value')
  15. end
  16. end
  17. describe 'valid inputs' do
  18. it { is_expected.to run.with_params({}) }
  19. it { is_expected.to run.with_params('key' => 'value') }
  20. it { is_expected.to run.with_params({}, 'key' => 'value') }
  21. it { is_expected.to run.with_params({ 'key1' => 'value1' }, 'key2' => 'value2') }
  22. end
  23. describe 'invalid inputs' do
  24. it { is_expected.to run.with_params([]).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  25. it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  26. it { is_expected.to run.with_params(true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  27. it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  28. it { is_expected.to run.with_params({}, []).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  29. it { is_expected.to run.with_params({}, 1).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  30. it { is_expected.to run.with_params({}, true).and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  31. it { is_expected.to run.with_params({}, 'one').and_raise_error(Puppet::ParseError, %r{is not a Hash}) }
  32. end
  33. end
  34. end