upcase_spec.rb 1.2 KB

1234567891011121314151617181920212223242526
  1. require 'spec_helper'
  2. describe 'upcase' 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. it { is_expected.to run.with_params('', '').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
  7. it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Requires an array, hash or object that responds to upcase}) }
  8. it { is_expected.to run.with_params([1]).and_raise_error(Puppet::ParseError, %r{Requires an array, hash or object that responds to upcase}) }
  9. end
  10. describe 'normal string handling' do
  11. it { is_expected.to run.with_params('abc').and_return('ABC') }
  12. it { is_expected.to run.with_params('Abc').and_return('ABC') }
  13. it { is_expected.to run.with_params('ABC').and_return('ABC') }
  14. end
  15. describe 'handling classes derived from String' do
  16. it { is_expected.to run.with_params(AlsoString.new('ABC')).and_return('ABC') }
  17. end
  18. describe 'strings in arrays handling' do
  19. it { is_expected.to run.with_params([]).and_return([]) }
  20. it { is_expected.to run.with_params(%w[One twO]).and_return(%w[ONE TWO]) }
  21. end
  22. end