command_mapper-gen 0.1.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.gitignore +10 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +20 -0
- data/Gemfile +17 -0
- data/LICENSE.txt +20 -0
- data/README.md +145 -0
- data/Rakefile +15 -0
- data/bin/command_mapper-gen +7 -0
- data/commnad_mapper-gen.gemspec +61 -0
- data/examples/grep.rb +63 -0
- data/gemspec.yml +26 -0
- data/lib/command_mapper/gen/arg.rb +43 -0
- data/lib/command_mapper/gen/argument.rb +53 -0
- data/lib/command_mapper/gen/cli.rb +233 -0
- data/lib/command_mapper/gen/command.rb +202 -0
- data/lib/command_mapper/gen/exceptions.rb +9 -0
- data/lib/command_mapper/gen/option.rb +66 -0
- data/lib/command_mapper/gen/option_value.rb +23 -0
- data/lib/command_mapper/gen/parsers/common.rb +49 -0
- data/lib/command_mapper/gen/parsers/help.rb +351 -0
- data/lib/command_mapper/gen/parsers/man.rb +80 -0
- data/lib/command_mapper/gen/parsers/options.rb +127 -0
- data/lib/command_mapper/gen/parsers/usage.rb +141 -0
- data/lib/command_mapper/gen/parsers.rb +2 -0
- data/lib/command_mapper/gen/task.rb +90 -0
- data/lib/command_mapper/gen/types/enum.rb +30 -0
- data/lib/command_mapper/gen/types/key_value.rb +34 -0
- data/lib/command_mapper/gen/types/list.rb +34 -0
- data/lib/command_mapper/gen/types/map.rb +36 -0
- data/lib/command_mapper/gen/types/num.rb +18 -0
- data/lib/command_mapper/gen/types/str.rb +48 -0
- data/lib/command_mapper/gen/types.rb +6 -0
- data/lib/command_mapper/gen/version.rb +6 -0
- data/lib/command_mapper/gen.rb +2 -0
- data/spec/argument_spec.rb +92 -0
- data/spec/cli_spec.rb +269 -0
- data/spec/command_spec.rb +316 -0
- data/spec/option_spec.rb +85 -0
- data/spec/option_value_spec.rb +20 -0
- data/spec/parsers/common_spec.rb +616 -0
- data/spec/parsers/help_spec.rb +612 -0
- data/spec/parsers/man_spec.rb +158 -0
- data/spec/parsers/options_spec.rb +802 -0
- data/spec/parsers/usage_spec.rb +1175 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/task_spec.rb +69 -0
- data/spec/types/enum_spec.rb +45 -0
- data/spec/types/key_value_spec.rb +36 -0
- data/spec/types/list_spec.rb +36 -0
- data/spec/types/map_spec.rb +48 -0
- data/spec/types/str_spec.rb +70 -0
- metadata +133 -0
@@ -0,0 +1,616 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'command_mapper/gen/parsers/common'
|
3
|
+
|
4
|
+
describe CommandMapper::Gen::Parsers::Common do
|
5
|
+
describe "#space" do
|
6
|
+
subject { super().space }
|
7
|
+
|
8
|
+
context "when given a ' '" do
|
9
|
+
let(:string) { ' ' }
|
10
|
+
|
11
|
+
it "must parse it" do
|
12
|
+
expect(subject.parse(string)).to eq(string)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when given multiple spaces" do
|
17
|
+
let(:string) { ' ' }
|
18
|
+
|
19
|
+
it "must not parse it" do
|
20
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when given a non-space character" do
|
25
|
+
let(:string) { 'A' }
|
26
|
+
|
27
|
+
it "must not parse it" do
|
28
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#spaces" do
|
34
|
+
subject { super().spaces }
|
35
|
+
|
36
|
+
context "when given an empty string" do
|
37
|
+
let(:string) { '' }
|
38
|
+
|
39
|
+
it "must not parse it" do
|
40
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when given one space" do
|
45
|
+
let(:string) { ' ' }
|
46
|
+
|
47
|
+
it "must parse it" do
|
48
|
+
expect(subject.parse(string)).to eq(string)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when given multiple spaces" do
|
53
|
+
let(:string) { ' ' }
|
54
|
+
|
55
|
+
it "must parse it" do
|
56
|
+
expect(subject.parse(string)).to eq(string)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "#space?" do
|
62
|
+
subject { super().space? }
|
63
|
+
|
64
|
+
context "when given an empty string" do
|
65
|
+
let(:string) { '' }
|
66
|
+
|
67
|
+
it "must parse it" do
|
68
|
+
expect(subject.parse(string)).to eq(string)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context "when given one space" do
|
73
|
+
let(:string) { ' ' }
|
74
|
+
|
75
|
+
it "must parse it" do
|
76
|
+
expect(subject.parse(string)).to eq(string)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when given multiple spaces" do
|
81
|
+
let(:string) { ' ' }
|
82
|
+
|
83
|
+
it "must not parse it" do
|
84
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe "#ellipsis" do
|
90
|
+
subject { super().ellipsis }
|
91
|
+
|
92
|
+
context "when given '...'" do
|
93
|
+
let(:string) { '...' }
|
94
|
+
|
95
|
+
it "must parse it" do
|
96
|
+
expect(subject.parse(string)).to eq(string)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "#ellipsis?" do
|
102
|
+
subject { super().ellipsis? }
|
103
|
+
|
104
|
+
context "when given an empty string" do
|
105
|
+
let(:string) { '' }
|
106
|
+
|
107
|
+
it "must parse it" do
|
108
|
+
expect(subject.parse(string)).to eq(string)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when given '...'" do
|
113
|
+
let(:string) { '...' }
|
114
|
+
|
115
|
+
it "must parse it" do
|
116
|
+
expect(subject.parse(string)).to eq({repeats: string})
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context "when given ' ...'" do
|
121
|
+
let(:string) { ' ...' }
|
122
|
+
|
123
|
+
it "must parse the '...'" do
|
124
|
+
expect(subject.parse(string)).to eq({repeats: string.strip})
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
describe "#capitalized_name" do
|
130
|
+
subject { super().capitalized_name }
|
131
|
+
|
132
|
+
context "when given a single lowercase character" do
|
133
|
+
let(:string) { 'a' }
|
134
|
+
|
135
|
+
it "must not parse it" do
|
136
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
context "when given a '-' character" do
|
141
|
+
let(:string) { '-' }
|
142
|
+
|
143
|
+
it "must not parse it" do
|
144
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "when given a '_' character" do
|
149
|
+
let(:string) { '_' }
|
150
|
+
|
151
|
+
it "must not parse it" do
|
152
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
context "when given one uppercase character" do
|
157
|
+
let(:string) { 'A' }
|
158
|
+
|
159
|
+
it "must not parse it" do
|
160
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
context "when more than one uppercase character" do
|
165
|
+
let(:string) { 'AB' }
|
166
|
+
|
167
|
+
it "must not parse it" do
|
168
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context "when given one uppercase character and a lowercase character" do
|
173
|
+
let(:string) { 'Ab' }
|
174
|
+
|
175
|
+
it "must parse it" do
|
176
|
+
expect(subject.parse(string)).to eq(string)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
context "when given one uppercase character followed by multiple lowercase characters" do
|
181
|
+
let(:string) { 'Abbbb' }
|
182
|
+
|
183
|
+
it "must parse it" do
|
184
|
+
expect(subject.parse(string)).to eq(string)
|
185
|
+
end
|
186
|
+
|
187
|
+
context "and it contains a '_' character" do
|
188
|
+
let(:string) { 'Abb_bb' }
|
189
|
+
|
190
|
+
it "must parse it" do
|
191
|
+
expect(subject.parse(string)).to eq(string)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "but it contains repeating '_' characters" do
|
196
|
+
let(:string) { 'Abb__bb' }
|
197
|
+
|
198
|
+
it "must not parse it" do
|
199
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context "and it contains a '-' character" do
|
204
|
+
let(:string) { 'Abb-bb' }
|
205
|
+
|
206
|
+
it "must parse it" do
|
207
|
+
expect(subject.parse(string)).to eq(string)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "but it contains repeating '-' characters" do
|
212
|
+
let(:string) { 'Abb--bb' }
|
213
|
+
|
214
|
+
it "must not parse it" do
|
215
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
context "when given two uppercase characters" do
|
221
|
+
let(:string) { 'AB' }
|
222
|
+
|
223
|
+
it "must not parse it" do
|
224
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
describe "#camelcase_name" do
|
230
|
+
subject { super().camelcase_name }
|
231
|
+
|
232
|
+
context "when given a single lowercase character" do
|
233
|
+
let(:string) { 'a' }
|
234
|
+
|
235
|
+
it "must not parse it" do
|
236
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
context "when given a '-' character" do
|
241
|
+
let(:string) { '-' }
|
242
|
+
|
243
|
+
it "must not parse it" do
|
244
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
context "when given a '_' character" do
|
249
|
+
let(:string) { '_' }
|
250
|
+
|
251
|
+
it "must not parse it" do
|
252
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
context "when given one uppercase character" do
|
257
|
+
let(:string) { 'A' }
|
258
|
+
|
259
|
+
it "must not parse it" do
|
260
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
context "when given one uppercase character and a lowercase character" do
|
265
|
+
let(:string) { 'Ab' }
|
266
|
+
|
267
|
+
it "must not parse it" do
|
268
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
context "when given one lowercase character" do
|
273
|
+
let(:string) { 'a' }
|
274
|
+
|
275
|
+
it "must not parse it" do
|
276
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
context "when given more than one lowercase characters" do
|
281
|
+
let(:string) { 'aaaaa' }
|
282
|
+
|
283
|
+
it "must not parse it" do
|
284
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
context "when given one or more lowercase characters then an uppercase character" do
|
289
|
+
let(:string) { 'aaaaaB' }
|
290
|
+
|
291
|
+
it "must not parse it" do
|
292
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
context "when given one or more lowercase characters, an uppercase character, then one or more lowercase characters" do
|
297
|
+
let(:string) { 'aaaaaBaaaa' }
|
298
|
+
|
299
|
+
it "must parse it" do
|
300
|
+
expect(subject.parse(string)).to eq(string)
|
301
|
+
end
|
302
|
+
|
303
|
+
context "and it contains a '_' character" do
|
304
|
+
let(:string) { 'aaa_Baa' }
|
305
|
+
|
306
|
+
it "must not parse it" do
|
307
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
context "but it contains repeating '_' characters" do
|
312
|
+
let(:string) { 'aaa__Baa' }
|
313
|
+
|
314
|
+
it "must not parse it" do
|
315
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
context "and it contains a '-' character" do
|
320
|
+
let(:string) { 'aaa-Baa' }
|
321
|
+
|
322
|
+
it "must not parse it" do
|
323
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
context "but it contains repeating '-' characters" do
|
328
|
+
let(:string) { 'aaa--Baa' }
|
329
|
+
|
330
|
+
it "must not parse it" do
|
331
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
describe "#lowercase_name" do
|
338
|
+
subject { super().lowercase_name }
|
339
|
+
|
340
|
+
context "when given a '_' character" do
|
341
|
+
let(:string) { '_' }
|
342
|
+
|
343
|
+
it "must not parse it" do
|
344
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
345
|
+
end
|
346
|
+
end
|
347
|
+
|
348
|
+
context "when given one lowercase character" do
|
349
|
+
let(:string) { 'a' }
|
350
|
+
|
351
|
+
it "must parse it" do
|
352
|
+
expect(subject.parse(string)).to eq(string)
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
context "when given multiple lowercase characters" do
|
357
|
+
let(:string) { 'ab' }
|
358
|
+
|
359
|
+
it "must parse it" do
|
360
|
+
expect(subject.parse(string)).to eq(string)
|
361
|
+
end
|
362
|
+
|
363
|
+
context "and it contains a '_' character" do
|
364
|
+
let(:string) { 'abb_bb' }
|
365
|
+
|
366
|
+
it "must parse it" do
|
367
|
+
expect(subject.parse(string)).to eq(string)
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
context "but it contains repeating '_' characters" do
|
372
|
+
let(:string) { 'abb__bb' }
|
373
|
+
|
374
|
+
it "must not parse it" do
|
375
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
376
|
+
end
|
377
|
+
end
|
378
|
+
|
379
|
+
context "and it contains a '-' character" do
|
380
|
+
let(:string) { 'abb-bb' }
|
381
|
+
|
382
|
+
it "must parse it" do
|
383
|
+
expect(subject.parse(string)).to eq(string)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
context "but it contains repeating '-' characters" do
|
388
|
+
let(:string) { 'abb--bb' }
|
389
|
+
|
390
|
+
it "must not parse it" do
|
391
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
context "when given a single uppercase characters" do
|
397
|
+
let(:string) { 'A' }
|
398
|
+
|
399
|
+
it "must not parse it" do
|
400
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
401
|
+
end
|
402
|
+
end
|
403
|
+
|
404
|
+
context "when it contains a uppercase character" do
|
405
|
+
let(:string) { 'aaaaBaaaa' }
|
406
|
+
|
407
|
+
it "must not parse it" do
|
408
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
409
|
+
end
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
413
|
+
describe "#uppercase_name" do
|
414
|
+
subject { super().uppercase_name }
|
415
|
+
|
416
|
+
context "when given a '_' character" do
|
417
|
+
let(:string) { '_' }
|
418
|
+
|
419
|
+
it "must not parse it" do
|
420
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
421
|
+
end
|
422
|
+
end
|
423
|
+
|
424
|
+
context "when given one uppercase character" do
|
425
|
+
let(:string) { 'A' }
|
426
|
+
|
427
|
+
it "must parse it" do
|
428
|
+
expect(subject.parse(string)).to eq(string)
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
context "when given multiple uppercase characters" do
|
433
|
+
let(:string) { 'AB' }
|
434
|
+
|
435
|
+
it "must parse it" do
|
436
|
+
expect(subject.parse(string)).to eq(string)
|
437
|
+
end
|
438
|
+
|
439
|
+
context "and it contains a '_' character" do
|
440
|
+
let(:string) { 'ABB_BB' }
|
441
|
+
|
442
|
+
it "must parse it" do
|
443
|
+
expect(subject.parse(string)).to eq(string)
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
context "but it contains repeating '_' characters" do
|
448
|
+
let(:string) { 'ABB__BB' }
|
449
|
+
|
450
|
+
it "must not parse it" do
|
451
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
context "and it contains a '-' character" do
|
456
|
+
let(:string) { 'ABB-BB' }
|
457
|
+
|
458
|
+
it "must parse it" do
|
459
|
+
expect(subject.parse(string)).to eq(string)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
context "but it contains repeating '-' characters" do
|
464
|
+
let(:string) { 'ABB--BB' }
|
465
|
+
|
466
|
+
it "must not parse it" do
|
467
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
context "when given a single lowercase characters" do
|
473
|
+
let(:string) { 'a' }
|
474
|
+
|
475
|
+
it "must not parse it" do
|
476
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
context "when it contains a uppercase character" do
|
481
|
+
let(:string) { 'AAAAbAAAA' }
|
482
|
+
|
483
|
+
it "must not parse it" do
|
484
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
describe "#short_flag" do
|
490
|
+
subject { super().short_flag }
|
491
|
+
|
492
|
+
context "when given a single '-'" do
|
493
|
+
let(:string) { '-' }
|
494
|
+
|
495
|
+
it "must not parse it" do
|
496
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
context "when given a '-' and a lowercase alphabetic character" do
|
501
|
+
let(:string) { '-a' }
|
502
|
+
|
503
|
+
it "must parse it" do
|
504
|
+
expect(subject.parse(string)).to eq(string)
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
context "when given a '-' and a uppercase alphabetic character" do
|
509
|
+
let(:string) { '-A' }
|
510
|
+
|
511
|
+
it "must parse it" do
|
512
|
+
expect(subject.parse(string)).to eq(string)
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
context "when given a '-' and a numeric character" do
|
517
|
+
let(:string) { '-0' }
|
518
|
+
|
519
|
+
it "must parse it" do
|
520
|
+
expect(subject.parse(string)).to eq(string)
|
521
|
+
end
|
522
|
+
end
|
523
|
+
|
524
|
+
context "when given a '-' and a '#' character" do
|
525
|
+
let(:string) { '-#' }
|
526
|
+
|
527
|
+
it "must parse it" do
|
528
|
+
expect(subject.parse(string)).to eq(string)
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
context "when given '--'" do
|
533
|
+
let(:string) { '--' }
|
534
|
+
|
535
|
+
it "must not parse it" do
|
536
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
537
|
+
end
|
538
|
+
end
|
539
|
+
|
540
|
+
context "when given '-_'" do
|
541
|
+
let(:string) { '-_' }
|
542
|
+
|
543
|
+
it "must not parse it" do
|
544
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
545
|
+
end
|
546
|
+
end
|
547
|
+
end
|
548
|
+
|
549
|
+
describe "#long_flag" do
|
550
|
+
subject { super().long_flag }
|
551
|
+
|
552
|
+
context "when given a '--'" do
|
553
|
+
let(:string) { '-' }
|
554
|
+
|
555
|
+
it "must not parse it" do
|
556
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
|
560
|
+
context "when given a '--' and a lowercase alphabetic character" do
|
561
|
+
let(:string) { '--a' }
|
562
|
+
|
563
|
+
it "must not parse it" do
|
564
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
565
|
+
end
|
566
|
+
end
|
567
|
+
|
568
|
+
context "when given a '--' and a uppercase alphabetic character" do
|
569
|
+
let(:string) { '--A' }
|
570
|
+
|
571
|
+
it "must not parse it" do
|
572
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
573
|
+
end
|
574
|
+
end
|
575
|
+
|
576
|
+
context "when given a '--' and a numeric character" do
|
577
|
+
let(:string) { '--0' }
|
578
|
+
|
579
|
+
it "must not parse it" do
|
580
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
581
|
+
end
|
582
|
+
end
|
583
|
+
|
584
|
+
context "when given a '---'" do
|
585
|
+
let(:string) { '---' }
|
586
|
+
|
587
|
+
it "must not parse it" do
|
588
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
589
|
+
end
|
590
|
+
end
|
591
|
+
|
592
|
+
context "when given a '--' and an underscore" do
|
593
|
+
let(:string) { '--_' }
|
594
|
+
|
595
|
+
it "must not parse it" do
|
596
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
597
|
+
end
|
598
|
+
end
|
599
|
+
|
600
|
+
context "when the string contains repeating '-' characters" do
|
601
|
+
let(:string) { '--foo--bar' }
|
602
|
+
|
603
|
+
it "must not parse it" do
|
604
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
605
|
+
end
|
606
|
+
end
|
607
|
+
|
608
|
+
context "when the string contains repeating '_' characters" do
|
609
|
+
let(:string) { '--foo__bar' }
|
610
|
+
|
611
|
+
it "must not parse it" do
|
612
|
+
expect { subject.parse(string) }.to raise_error(Parslet::ParseFailed)
|
613
|
+
end
|
614
|
+
end
|
615
|
+
end
|
616
|
+
end
|