getvar_spec.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. require 'spec_helper'
  2. describe 'getvar' do
  3. it { is_expected.not_to eq(nil) }
  4. it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
  5. it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) }
  6. it { is_expected.to run.with_params('$::foo').and_return(nil) }
  7. context 'with given variables in namespaces' do
  8. let(:pre_condition) do
  9. <<-PUPPETCODE
  10. class site::data { $foo = 'baz' }
  11. include site::data
  12. PUPPETCODE
  13. end
  14. it { is_expected.to run.with_params('site::data::foo').and_return('baz') }
  15. it { is_expected.to run.with_params('::site::data::foo').and_return('baz') }
  16. it { is_expected.to run.with_params('::site::data::bar').and_return(nil) }
  17. end
  18. context 'with given variables in namespaces' do
  19. let(:pre_condition) do
  20. <<-PUPPETCODE
  21. class site::info { $lock = 'ŧҺîš íš ắ śţřĭŋĝ' }
  22. class site::new { $item = '万Ü€‰' }
  23. include site::info
  24. include site::new
  25. PUPPETCODE
  26. end
  27. it { is_expected.to run.with_params('site::info::lock').and_return('ŧҺîš íš ắ śţřĭŋĝ') }
  28. it { is_expected.to run.with_params('::site::new::item').and_return('万Ü€‰') }
  29. end
  30. end