validate_array_spec.rb 1.7 KB

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