getparam_spec.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334
  1. require 'spec_helper'
  2. describe 'getparam' do
  3. it { is_expected.not_to eq(nil) }
  4. it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{Must specify a reference}) }
  5. it { is_expected.to run.with_params('User[one]').and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
  6. it { is_expected.to run.with_params('User[one]', 2).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
  7. it { is_expected.to run.with_params('User[one]', []).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
  8. it { is_expected.to run.with_params('User[one]', {}).and_raise_error(ArgumentError, %r{Must specify name of a parameter}) }
  9. describe 'when compared against a user resource with no params' do
  10. let(:pre_condition) { 'user { "one": }' }
  11. it { is_expected.to run.with_params('User[one]', 'ensure').and_return('') }
  12. it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
  13. it { is_expected.to run.with_params('User[one]', 'shell').and_return('') }
  14. end
  15. describe 'when compared against a user resource with params' do
  16. let(:pre_condition) { 'user { "one": ensure => present, shell => "/bin/sh", managehome => false, }' }
  17. it { is_expected.to run.with_params('User[one]', 'ensure').and_return('present') }
  18. it { is_expected.to run.with_params('User[two]', 'ensure').and_return('') }
  19. it { is_expected.to run.with_params('User[one]', 'shell').and_return('/bin/sh') }
  20. it { is_expected.to run.with_params('User[one]', 'managehome').and_return(false) }
  21. end
  22. describe 'when compared against a user resource with UTF8 and double byte params' do
  23. let(:pre_condition) { 'user { ["三", "ƒốưř"]: ensure => present }' }
  24. it { is_expected.to run.with_params('User[三]', 'ensure').and_return('present') }
  25. it { is_expected.to run.with_params('User[ƒốưř]', 'ensure').and_return('present') }
  26. end
  27. end