create_ini_settings_spec.rb 1.0 KB

123456789101112131415161718192021222324
  1. #! /usr/bin/env ruby
  2. require 'spec_helper'
  3. require 'rspec-puppet'
  4. describe 'create_ini_settings' do
  5. before :each do
  6. Puppet::Parser::Functions.autoloader.loadall
  7. Puppet::Parser::Functions.function(:create_resources)
  8. end
  9. describe 'argument handling' do
  10. it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, /0 for 1 or 2/) }
  11. it { is_expected.to run.with_params(1,2,3).and_raise_error(Puppet::ParseError, /3 for 1 or 2/) }
  12. it { is_expected.to run.with_params('foo').and_raise_error(Puppet::ParseError, /Requires all arguments/) }
  13. it { is_expected.to run.with_params({},'foo').and_raise_error(Puppet::ParseError, /Requires all arguments/) }
  14. it { is_expected.to run.with_params({}) }
  15. it { is_expected.to run.with_params({},{}) }
  16. it { is_expected.to run.with_params({ 'section' => { 'setting' => 'value' }}).and_raise_error(Puppet::ParseError, /must pass the path parameter/) }
  17. it { is_expected.to run.with_params({ 1 => 2 }).and_raise_error(Puppet::ParseError, /Section 1 must contain a Hash/) }
  18. end
  19. end