-describe Puppet::Parser::Functions.function(:validate_augeas), :if => Puppet.features.augeas? do
- let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
- # The subject of these examplres is the method itself.
- subject do
- # This makes sure the function is loaded within each test
- function_name = Puppet::Parser::Functions.function(:validate_augeas)
- scope.method(function_name)
- end
-
- context 'Using Puppet::Parser::Scope.new' do
-
- describe 'Garbage inputs' do
- inputs = [
- [ nil ],
- [ [ nil ] ],
- [ { 'foo' => 'bar' } ],
- [ { } ],
- [ '' ],
- [ "one", "one", "MSG to User", "4th arg" ],
- ]
-
- inputs.each do |input|
- it "validate_augeas(#{input.inspect}) should fail" do
- expect { subject.call [input] }.to raise_error Puppet::ParseError
- end
- end
+describe 'validate_augeas' do
+ unless Puppet.features.augeas?
+ skip "ruby-augeas not installed"
+ else
+ describe 'signature validation' do
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params().and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+ it { is_expected.to run.with_params('').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+ it { is_expected.to run.with_params('', '', [], '', 'extra').and_raise_error(Puppet::ParseError, /wrong number of arguments/i) }
+ it { is_expected.to run.with_params('one', 'one', 'MSG to User', '4th arg').and_raise_error(NoMethodError) }