-describe "the delete_values function" do
- let(:scope) { PuppetlabsSpec::PuppetInternals.scope }
-
- it "should exist" do
- expect(Puppet::Parser::Functions.function("delete_values")).to eq("function_delete_values")
- end
-
- it "should raise a ParseError if there are fewer than 2 arguments" do
- expect { scope.function_delete_values([]) }.to( raise_error(Puppet::ParseError))
- end
-
- it "should raise a ParseError if there are greater than 2 arguments" do
- expect { scope.function_delete_values([[], 'foo', 'bar']) }.to( raise_error(Puppet::ParseError))
- end
-
- it "should raise a TypeError if the argument is not a hash" do
- expect { scope.function_delete_values([1,'bar']) }.to( raise_error(TypeError))
- expect { scope.function_delete_values(['foo','bar']) }.to( raise_error(TypeError))
- expect { scope.function_delete_values([[],'bar']) }.to( raise_error(TypeError))
+describe 'delete_values' do
+ it { is_expected.not_to eq(nil) }
+ it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) }
+ it { is_expected.to run.with_params(1).and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) }
+ it { is_expected.to run.with_params('one').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) }
+ it { is_expected.to run.with_params('one', 'two', 'three').and_raise_error(Puppet::ParseError, %r{Wrong number of arguments}) }
+ describe 'when the first argument is not a hash' do
+ it { is_expected.to run.with_params(1, 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) }
+ it { is_expected.to run.with_params('one', 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) }
+ it { is_expected.to run.with_params([], 'two').and_raise_error(TypeError, %r{First argument must be a Hash}) }