diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-29 13:29:17 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-29 13:29:17 -0700 |
| commit | 97ae812f0a67ef01daed4e9220981e2bc7c70603 (patch) | |
| tree | 1502f21bff17b7ef823e821ce2f5a35804c6757a /spec | |
| parent | 1707f2779e37f231191cf5234e4e309055717374 (diff) | |
| download | puppet-97ae812f0a67ef01daed4e9220981e2bc7c70603.tar.gz puppet-97ae812f0a67ef01daed4e9220981e2bc7c70603.tar.xz puppet-97ae812f0a67ef01daed4e9220981e2bc7c70603.zip | |
(#7248) Fail if two aliases of one option are passed...
From the command line, and other facades, it is fairly difficult to call an
action with two aliases of the same option in the invocation, but from the
Ruby API it would be relatively easy to achieve.
This is now checked, and raises an error, so that we don't accidentally have
strange or unusual behaviour coming out of the whole system.
Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'spec')
| -rwxr-xr-x | spec/unit/interface/action_spec.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb index 23d0de490..f6796a82b 100755 --- a/spec/unit/interface/action_spec.rb +++ b/spec/unit/interface/action_spec.rb @@ -445,4 +445,23 @@ describe Puppet::Interface::Action do it "should fail if a second block is given for the same type" it "should return the block if asked" end + + context "#validate_args" do + subject do + Puppet::Interface.new(:validate_args, '1.0.0') do + script :test do true end + end + end + + it "should fail if a required option is not passed" do + subject.option "--foo" do required end + expect { subject.test }.to raise_error ArgumentError, /options are required/ + end + + it "should fail if two aliases to one option are passed" do + subject.option "--foo", "-f" + expect { subject.test :foo => true, :f => true }. + to raise_error ArgumentError, /Multiple aliases for the same option/ + end + end end |
