summaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorDaniel Pittman <daniel@puppetlabs.com>2011-03-30 16:56:40 -0700
committerDaniel Pittman <daniel@puppetlabs.com>2011-04-04 10:19:53 -0700
commit512778f95058a423a3d2e08d1803eb4a90fb975a (patch)
treec2bdda6ef44b3e040a4272f576cbdc4528f961d5 /spec
parent3bb614525f625a688baf8d67c5a580f8a51f4cad (diff)
downloadpuppet-512778f95058a423a3d2e08d1803eb4a90fb975a.tar.gz
puppet-512778f95058a423a3d2e08d1803eb4a90fb975a.tar.xz
puppet-512778f95058a423a3d2e08d1803eb4a90fb975a.zip
(#6749) detect duplicate aliases in a single option statement.
This ensures that an option declaration that shadows itself is found, and reported to the user, rather than silently eating one of the two. This could have actually lost, for example, the distinction between an argument-requiring and an argument-missing variant of the same thing. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
Diffstat (limited to 'spec')
-rw-r--r--spec/shared_behaviours/things_that_declare_options.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/shared_behaviours/things_that_declare_options.rb b/spec/shared_behaviours/things_that_declare_options.rb
index 6abce99e3..1b41c2279 100644
--- a/spec/shared_behaviours/things_that_declare_options.rb
+++ b/spec/shared_behaviours/things_that_declare_options.rb
@@ -53,6 +53,20 @@ shared_examples_for "things that declare options" do
}.should raise_error ArgumentError, /Option f conflicts with existing option f/
end
+ ["-f", "--foo"].each do |option|
+ ["", " FOO", "=FOO", " [FOO]", "=[FOO]"].each do |argument|
+ input = option + argument
+ it "should detect conflicts within a single option like #{input.inspect}" do
+ expect {
+ add_options_to do
+ option input, input
+ end
+ }.should raise_error ArgumentError, /duplicates existing alias/
+ end
+ end
+ end
+
+
# Verify the range of interesting conflicts to check for ordering causing
# the behaviour to change, or anything exciting like that.
[ %w{--foo}, %w{-f}, %w{-f --foo}, %w{--baz -f},