|
14 | 14 | expect(@logs).to be_empty |
15 | 15 | end |
16 | 16 |
|
17 | | - it "parses a 'long' option with a value and converts '-' to '_' & warns" do |
18 | | - parses( |
19 | | - :option => ["--an_gry", "Angry", :REQUIRED], |
20 | | - :from_arguments => ["--an-gry", "foo"], |
21 | | - :expects => "foo" |
22 | | - ) |
23 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --an_gry, got --an-gry. Partial argument matching is deprecated and will be removed in a future release./) |
| 17 | + it "raises for a 'long' option where '-' and '_' don't match exactly" do |
| 18 | + option_parser.on("--an_gry", "Angry", :REQUIRED) { |val| } |
| 19 | + expect { option_parser.parse(["--an-gry", "foo"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
24 | 20 | end |
25 | 21 |
|
26 | | - it "parses a 'long' option with a value and converts '_' to '-' & warns" do |
27 | | - parses( |
28 | | - :option => ["--an-gry", "Angry", :REQUIRED], |
29 | | - :from_arguments => ["--an_gry", "foo"], |
30 | | - :expects => "foo" |
31 | | - ) |
32 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --an-gry, got --an_gry. Partial argument matching is deprecated and will be removed in a future release./) |
| 22 | + it "raises for a 'long' option where '_' and '-' don't match exactly" do |
| 23 | + option_parser.on("--an-gry", "Angry", :REQUIRED) { |val| } |
| 24 | + expect { option_parser.parse(["--an_gry", "foo"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
33 | 25 | end |
34 | 26 |
|
35 | 27 | it "parses a 'short' option with a value" do |
|
60 | 52 | ) |
61 | 53 | end |
62 | 54 |
|
63 | | - it "converts '_' to '-' with a 'long' option & warns" do |
64 | | - parses( |
65 | | - :option => ["--an-gry", "Angry", :NONE], |
66 | | - :from_arguments => ["--an_gry"], |
67 | | - :expects => true |
68 | | - ) |
69 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --an-gry, got --an_gry. Partial argument matching is deprecated and will be removed in a future release./) |
| 55 | + it "raises for a 'long' option where '_' and '-' don't match exactly" do |
| 56 | + option_parser.on("--an-gry", "Angry", :NONE) { |val| } |
| 57 | + expect { option_parser.parse(["--an_gry"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
70 | 58 | end |
71 | 59 |
|
72 | | - it "converts '-' to '_' with a 'long' option & warns" do |
73 | | - parses( |
74 | | - :option => ["--an_gry", "Angry", :NONE], |
75 | | - :from_arguments => ["--an-gry"], |
76 | | - :expects => true |
77 | | - ) |
78 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --an_gry, got --an-gry. Partial argument matching is deprecated and will be removed in a future release./) |
| 60 | + it "raises for a 'long' option where '-' and '_' don't match exactly" do |
| 61 | + option_parser.on("--an_gry", "Angry", :NONE) { |val| } |
| 62 | + expect { option_parser.parse(["--an-gry"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
79 | 63 | end |
80 | 64 |
|
81 | 65 | it "parses a 'short' option" do |
|
95 | 79 | expect(@logs).to be_empty |
96 | 80 | end |
97 | 81 |
|
98 | | - it "resolves '-' to '_' with '--no-blah' syntax" do |
99 | | - parses( |
100 | | - :option => ["--[no-]an_gry", "Angry", :NONE], |
101 | | - :from_arguments => ["--no-an-gry"], |
102 | | - :expects => false |
103 | | - ) |
104 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --\[no-\]an_gry, got --no-an-gry. Partial argument matching is deprecated and will be removed in a future release./) |
| 82 | + it "raises for '--no-blah' syntax where '-' and '_' don't match exactly" do |
| 83 | + option_parser.on("--[no-]an_gry", "Angry", :NONE) { |val| } |
| 84 | + expect { option_parser.parse(["--no-an-gry"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
105 | 85 | end |
106 | 86 |
|
107 | | - it "resolves '_' to '-' with '--no-blah' syntax" do |
108 | | - parses( |
109 | | - :option => ["--[no-]an-gry", "Angry", :NONE], |
110 | | - :from_arguments => ["--no-an_gry"], |
111 | | - :expects => false |
112 | | - ) |
113 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --\[no-\]an-gry, got --no-an_gry. Partial argument matching is deprecated and will be removed in a future release./) |
| 87 | + it "raises for '--no-blah' syntax where '_' and '-' don't match exactly" do |
| 88 | + option_parser.on("--[no-]an-gry", "Angry", :NONE) { |val| } |
| 89 | + expect { option_parser.parse(["--no-an_gry"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
114 | 90 | end |
115 | 91 |
|
116 | | - it "resolves '-' to '_' & warns when option is defined with '--no-blah syntax' but argument is given in '--option' syntax" do |
117 | | - parses( |
118 | | - :option => ["--[no-]rag-e", "Rage", :NONE], |
119 | | - :from_arguments => ["--rag_e"], |
120 | | - :expects => true |
121 | | - ) |
122 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --\[no-\]rag-e, got --rag_e. Partial argument matching is deprecated and will be removed in a future release./) |
123 | | - end |
| 92 | + it "raises when option is defined with '--no-blah' syntax but '-' and '_' don't match exactly" do |
| 93 | + option_parser.on("--[no-]rag-e", "Rage", :NONE) { |val| } |
| 94 | + expect { option_parser.parse(["--rag_e"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
| 95 | + end |
124 | 96 |
|
125 | | - it "resolves '_' to '-' & warns when option is defined with '--no-blah syntax' but argument is given in '--option' syntax" do |
126 | | - parses( |
127 | | - :option => ["--[no-]rag_e", "Rage", :NONE], |
128 | | - :from_arguments => ["--rag-e"], |
129 | | - :expects => true |
130 | | - ) |
131 | | - expect(@logs).to have_matching_log(/Partial argument match detected: correct argument is --\[no-\]rag_e, got --rag-e. Partial argument matching is deprecated and will be removed in a future release./) |
132 | | - end |
| 97 | + it "raises when option is defined with '--no-blah' syntax but '_' and '-' don't match exactly" do |
| 98 | + option_parser.on("--[no-]rag_e", "Rage", :NONE) { |val| } |
| 99 | + expect { option_parser.parse(["--rag-e"]) }.to raise_error(Puppet::Util::CommandLine::PuppetOptionError) |
| 100 | + end |
133 | 101 |
|
134 | 102 | it "overrides a previous argument with a later one" do |
135 | 103 | parses( |
|
0 commit comments