summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-07-22 14:13:50 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-07-22 16:27:08 -0700
commit69b4e70ac2fa2b265f6c92d7de073d51ae25d3ed (patch)
tree668520dd895af37ff80ae9b95dc0dd3fd00bffb0 /spec
parent6bec2df0860b71730b99ddd9f1764aa2ce0dc960 (diff)
downloadpuppet-69b4e70ac2fa2b265f6c92d7de073d51ae25d3ed.tar.gz
puppet-69b4e70ac2fa2b265f6c92d7de073d51ae25d3ed.tar.xz
puppet-69b4e70ac2fa2b265f6c92d7de073d51ae25d3ed.zip
(#7290) Fail on unknown options.
Part of the "social contract" of Faces, Actions and Options is that the metadata we collect is authoritative: it covers everything that is possible. In the initial release we didn't enforce that around options. If you passed an unknown option in the hash, we just silently ignored it in validation and made it available down in the action. Now, instead, we enforce that rule. If you pass an unknown option we raise an error and complain; anything that gets to the action will be listed in the set of inspectable options. Cases that depended on this behaviour to pass arbitrary content in the hash should be rewritten to move that content down a level: take a hash value for one option, and use that for your free content. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'spec')
-rwxr-xr-xspec/unit/interface/action_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/unit/interface/action_spec.rb b/spec/unit/interface/action_spec.rb
index 848a44bba..66fff2571 100755
--- a/spec/unit/interface/action_spec.rb
+++ b/spec/unit/interface/action_spec.rb
@@ -565,6 +565,16 @@ describe Puppet::Interface::Action do
expect { subject.test :foo => true, :f => true }.
to raise_error ArgumentError, /Multiple aliases for the same option/
end
+
+ it "should fail if an unknown option is passed" do
+ expect { subject.test :unknown => true }.
+ to raise_error ArgumentError, /Unknown options passed: unknown/
+ end
+
+ it "should report all the unknown options passed" do
+ expect { subject.test :unknown => true, :unseen => false }.
+ to raise_error ArgumentError, /Unknown options passed: unknown, unseen/
+ end
end
context "default option values" do