ini_setting_spec.rb 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #
  2. # these tests are a little concerning b/c they are hacking around the
  3. # modulepath, so these tests will not catch issues that may eventually arise
  4. # related to loading these plugins.
  5. # I could not, for the life of me, figure out how to programatcally set the modulepath
  6. $LOAD_PATH.push(
  7. File.join(
  8. File.dirname(__FILE__),
  9. '..',
  10. '..',
  11. '..',
  12. 'fixtures',
  13. 'modules',
  14. 'inifile',
  15. 'lib')
  16. )
  17. $LOAD_PATH.push(
  18. File.join(
  19. File.dirname(__FILE__),
  20. '..',
  21. '..',
  22. '..',
  23. 'fixtures',
  24. 'modules',
  25. 'openstacklib',
  26. 'lib')
  27. )
  28. require 'spec_helper'
  29. provider_class = Puppet::Type.type(:novajoin_config).provider(:ini_setting)
  30. describe provider_class do
  31. it 'should default to the default setting when no other one is specified' do
  32. resource = Puppet::Type::Novajoin_config.new(
  33. {:name => 'DEFAULT/foo', :value => 'bar'}
  34. )
  35. provider = provider_class.new(resource)
  36. expect(provider.section).to eq('DEFAULT')
  37. expect(provider.setting).to eq('foo')
  38. end
  39. it 'should allow setting to be set explicitly' do
  40. resource = Puppet::Type::Novajoin_config.new(
  41. {:name => 'dude/foo', :value => 'bar'}
  42. )
  43. provider = provider_class.new(resource)
  44. expect(provider.section).to eq('dude')
  45. expect(provider.setting).to eq('foo')
  46. end
  47. it 'should ensure absent when <SERVICE DEFAULT> is specified as a value' do
  48. resource = Puppet::Type::Novajoin_config.new(
  49. {:name => 'dude/foo', :value => '<SERVICE DEFAULT>'}
  50. )
  51. provider = provider_class.new(resource)
  52. provider.exists?
  53. expect(resource[:ensure]).to eq :absent
  54. end
  55. it 'should ensure absent when value matches ensure_absent_val' do
  56. resource = Puppet::Type::Novajoin_config.new(
  57. {:name => 'dude/foo', :value => 'foo', :ensure_absent_val => 'foo' }
  58. )
  59. provider = provider_class.new(resource)
  60. provider.exists?
  61. expect(resource[:ensure]).to eq :absent
  62. end
  63. end