|
48 | 48 | end |
49 | 49 | end |
50 | 50 |
|
51 | | - describe '#args' do |
52 | | - it 'returns an array of Argument objects' do |
53 | | - expect(subject.args).to be_an Array |
54 | | - expect(subject.args.first).to be_a Script::Argument |
55 | | - end |
56 | | - end |
57 | | - |
58 | 51 | describe '#caption_string' do |
59 | 52 | it 'returns a string containing the name and summary' do |
60 | 53 | expect(subject.caption_string).to eq 'get - get something from somewhere' |
|
69 | 62 | end |
70 | 63 | end |
71 | 64 |
|
72 | | - describe '#command_aliases' do |
73 | | - let(:fixture) { :aliases } |
74 | | - |
75 | | - it 'returns an array of command aliases' do |
76 | | - expect(subject.command_aliases).to eq %w[download d pull upload u push update upgrade] |
77 | | - end |
78 | | - end |
79 | | - |
80 | | - describe '#command_help_data' do |
81 | | - let(:fixture) { :exposed } |
82 | | - |
83 | | - it 'returns a hash suitable for showing command and exposed subcommand help' do |
84 | | - expect(subject.command_help_data.to_yaml) |
85 | | - .to match_approval('script/command/exposed_commands') |
86 | | - end |
87 | | - end |
88 | | - |
89 | | - describe '#command_names' do |
90 | | - let(:fixture) { :docker } |
91 | | - |
92 | | - it 'returns an array of command names' do |
93 | | - expect(subject.command_names).to eq %w[container image] |
94 | | - end |
95 | | - end |
96 | | - |
97 | | - describe '#commands' do |
98 | | - let(:fixture) { :docker } |
99 | | - |
100 | | - it 'returns an array of Command objects' do |
101 | | - expect(subject.commands).to be_an Array |
102 | | - expect(subject.commands.first).to be_a described_class |
103 | | - end |
104 | | - |
105 | | - it 'sets the parents property of its commands' do |
106 | | - expect(subject.commands.first.parents).to eq ['docker'] |
107 | | - end |
108 | | - end |
109 | | - |
110 | | - describe '#deep_commands' do |
111 | | - let(:fixture) { :docker } |
112 | | - |
113 | | - it 'returns an array of all commands in the tree' do |
114 | | - expect(subject.deep_commands.map(&:full_name)) |
115 | | - .to eq ['docker container', 'docker container run', 'docker container stop', 'docker image'] |
116 | | - end |
117 | | - |
118 | | - context 'when include_self is true' do |
119 | | - it 'prepends the result with the command itself' do |
120 | | - expect(subject.deep_commands(include_self: true).map(&:full_name)) |
121 | | - .to eq ['docker', 'docker container', 'docker container run', 'docker container stop', 'docker image'] |
122 | | - end |
123 | | - end |
124 | | - end |
125 | | - |
126 | | - describe '#default_arguments' do |
127 | | - let(:fixture) { :default_values } |
128 | | - |
129 | | - it 'returns an array of only the Argument objects that have default' do |
130 | | - expect(subject.default_args.size).to eq 1 |
131 | | - expect(subject.default_args.first.name).to eq 'files' |
132 | | - end |
133 | | - end |
134 | | - |
135 | | - describe '#default_command' do |
136 | | - let(:fixture) { :default_command } |
137 | | - |
138 | | - it 'returns a Command object of the first default command' do |
139 | | - expect(subject.default_command).to be_a described_class |
140 | | - expect(subject.default_command.name).to eq 'get' |
141 | | - end |
142 | | - end |
143 | | - |
144 | | - describe '#default_flags' do |
145 | | - let(:fixture) { :default_values } |
146 | | - |
147 | | - it 'returns an array of only the Flags objects that have default' do |
148 | | - expect(subject.default_flags.size).to eq 1 |
149 | | - expect(subject.default_flags.first.long).to eq '--format' |
150 | | - end |
151 | | - end |
152 | | - |
153 | | - describe '#dependencies' do |
154 | | - let(:fixture) { :dependencies } |
155 | | - |
156 | | - it 'returns an array of Dependency objects' do |
157 | | - expect(subject.dependencies).to be_an Array |
158 | | - expect(subject.dependencies.first).to be_a Script::Dependency |
159 | | - end |
160 | | - end |
161 | | - |
162 | | - describe '#environment_cariables' do |
163 | | - it 'returns an array of EnvironmentVariable objects' do |
164 | | - expect(subject.environment_variables).to be_an Array |
165 | | - expect(subject.environment_variables.first).to be_a Script::EnvironmentVariable |
166 | | - end |
167 | | - end |
168 | | - |
169 | | - describe '#examples' do |
170 | | - context 'when there are no examples' do |
171 | | - it 'returns nil' do |
172 | | - expect(subject.examples).to be_nil |
173 | | - end |
174 | | - end |
175 | | - |
176 | | - context 'when there are examples as array' do |
177 | | - let(:fixture) { :examples_array } |
178 | | - |
179 | | - it 'returns the array' do |
180 | | - expect(subject.examples).to be_an Array |
181 | | - end |
182 | | - end |
183 | | - |
184 | | - context 'when there are examples as string' do |
185 | | - let(:fixture) { :examples_string } |
186 | | - |
187 | | - it 'returns an array with one item' do |
188 | | - expect(subject.examples).to be_an Array |
189 | | - expect(subject.examples.count).to eq 1 |
190 | | - expect(subject.examples.first).to start_with 'Download a file' |
191 | | - end |
192 | | - end |
193 | | - end |
194 | | - |
195 | 65 | describe '#filename' do |
196 | 66 | context 'when it is the root command' do |
197 | 67 | it 'returns root_command.sh' do |
|
251 | 121 | end |
252 | 122 | end |
253 | 123 |
|
254 | | - describe '#flags' do |
255 | | - it 'returns an array of Flag objects' do |
256 | | - expect(subject.flags).to be_an Array |
257 | | - expect(subject.flags.first).to be_a Script::Flag |
258 | | - end |
259 | | - end |
260 | | - |
261 | 124 | describe '#function_name' do |
262 | 125 | let(:fixture) { :docker_container_run } |
263 | 126 |
|
|
290 | 153 | end |
291 | 154 | end |
292 | 155 |
|
293 | | - describe '#global_flags?' do |
294 | | - context 'when a command has flags and commands' do |
295 | | - let(:fixture) { :mode_global_flags } |
296 | | - |
297 | | - it 'returns true' do |
298 | | - expect(subject).to be_global_flags |
299 | | - end |
300 | | - end |
301 | | - |
302 | | - context 'when a command has flags but no commands' do |
303 | | - let(:fixture) { :mode_flags } |
304 | | - |
305 | | - it 'returns false' do |
306 | | - expect(subject).not_to be_global_flags |
307 | | - end |
308 | | - end |
309 | | - |
310 | | - context 'when a command has commands but no flags' do |
311 | | - let(:fixture) { :mode_commands } |
312 | | - |
313 | | - it 'returns false' do |
314 | | - expect(subject).not_to be_global_flags |
315 | | - end |
316 | | - end |
317 | | - end |
318 | | - |
319 | 156 | describe '#group_string' do |
320 | 157 | it 'returns a string suitable for showing the group in usage' do |
321 | 158 | expect(subject.group_string).to eq 'Commands:' |
|
330 | 167 | end |
331 | 168 | end |
332 | 169 |
|
333 | | - describe '#grouped_commands' do |
334 | | - let(:fixture) { :exposed } |
335 | | - |
336 | | - it 'returns a hash with an array of Command objects per group key' do |
337 | | - expect(subject.grouped_commands.keys).to contain_exactly('Cluster Commands:', 'Commands:') |
338 | | - expect(subject.grouped_commands['Commands:'].count).to eq 4 |
339 | | - expect(subject.grouped_commands['Commands:']).to all(be_a described_class) |
340 | | - end |
341 | | - end |
342 | | - |
343 | 170 | describe '#has_unique_args_or_flags?' do |
344 | 171 | context 'when the command has any args that are unique' do |
345 | 172 | let(:fixture) { :unique_args } |
|
455 | 282 | end |
456 | 283 | end |
457 | 284 |
|
458 | | - describe '#needy_flags' do |
459 | | - let(:fixture) { :needy_flags } |
460 | | - |
461 | | - it 'returns an array of only the needy Flag objects' do |
462 | | - expect(subject.needy_flags.size).to eq 2 |
463 | | - expect(subject.needy_flags.first.long).to eq '--add' |
464 | | - end |
465 | | - end |
466 | | - |
467 | | - describe '#public_commands' do |
468 | | - let(:fixture) { :private_commands } |
469 | | - |
470 | | - it 'returns an array of Command objects excluding private commands' do |
471 | | - expect(subject.public_commands.count).to eq 1 |
472 | | - expect(subject.public_commands.first.name).to eq 'connect' |
473 | | - end |
474 | | - end |
475 | | - |
476 | | - describe '#public_commands_aliases' do |
477 | | - let(:fixture) { :private_commands } |
478 | | - |
479 | | - it 'returns an array of command aliases of public subcommands' do |
480 | | - expect(subject.public_command_aliases).to eq %w[connect c] |
481 | | - end |
482 | | - end |
483 | | - |
484 | | - describe '#required_args' do |
485 | | - it 'returns an array of only the required Argument objects' do |
486 | | - expect(subject.required_args.size).to eq 1 |
487 | | - expect(subject.required_args.first.name).to eq 'source' |
488 | | - end |
489 | | - end |
490 | | - |
491 | | - describe '#required_environment_variables' do |
492 | | - it 'returns an array of only the required Argument objects' do |
493 | | - expect(subject.required_environment_variables.size).to eq 1 |
494 | | - expect(subject.required_environment_variables.first.name).to eq 'secret_key' |
495 | | - end |
496 | | - end |
497 | | - |
498 | | - describe '#required_flags' do |
499 | | - it 'returns an array of only the required Flag objects' do |
500 | | - expect(subject.required_flags.size).to eq 1 |
501 | | - expect(subject.required_flags.first.long).to eq '--force' |
502 | | - end |
503 | | - end |
504 | | - |
505 | | - describe '#repeatable_arg_exist?' do |
506 | | - context 'when the command does not have any repeatable flags' do |
507 | | - it 'returns false' do |
508 | | - expect(subject.repeatable_arg_exist?).to be false |
509 | | - end |
510 | | - end |
511 | | - |
512 | | - context 'when the command has at least one repeatable flag' do |
513 | | - let(:fixture) { :repeatable_arg } |
514 | | - |
515 | | - it 'returns true' do |
516 | | - expect(subject.repeatable_arg_exist?).to be true |
517 | | - end |
518 | | - end |
519 | | - end |
520 | | - |
521 | 285 | describe '#root_command?' do |
522 | 286 | context 'when the command has no parents' do |
523 | 287 | it 'returns true' do |
|
534 | 298 | end |
535 | 299 | end |
536 | 300 |
|
537 | | - describe '#short_flag_exist?' do |
538 | | - let(:fixture) { :flag_hog } |
539 | | - |
540 | | - context 'when the command has this short flag' do |
541 | | - it 'returns true' do |
542 | | - expect(subject.short_flag_exist?('-h')).to be true |
543 | | - end |
544 | | - end |
545 | | - |
546 | | - context 'when the command does not have this short flag' do |
547 | | - it 'returns false' do |
548 | | - expect(subject.short_flag_exist?('-s')).to be false |
549 | | - end |
550 | | - end |
551 | | - end |
552 | | - |
553 | 301 | describe '#summary_string' do |
554 | 302 | it 'returns the user defined summary' do |
555 | 303 | expect(subject.summary_string).to eq 'get something from somewhere' |
|
678 | 426 | end |
679 | 427 | end |
680 | 428 | end |
681 | | - |
682 | | - describe '#whitelisted_args' do |
683 | | - let(:fixture) { :whitelist } |
684 | | - |
685 | | - it 'returns an array of args that have a whitelist' do |
686 | | - expect(subject.whitelisted_args.size).to eq 1 |
687 | | - expect(subject.whitelisted_args.first.name).to eq 'region' |
688 | | - end |
689 | | - end |
690 | | - |
691 | | - describe '#whitelisted_flags' do |
692 | | - let(:fixture) { :whitelist } |
693 | | - |
694 | | - it 'returns an array of flags that have a whitelist' do |
695 | | - expect(subject.whitelisted_flags.size).to eq 1 |
696 | | - expect(subject.whitelisted_flags.first.long).to eq '--user' |
697 | | - end |
698 | | - end |
699 | 429 | end |
0 commit comments