Skip to content

Commit c5abe1f

Browse files
committed
add specs for Command#public_command_aliases and Command#public_commands
1 parent 3002a61 commit c5abe1f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

spec/bashly/script/command_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,23 @@
339339
end
340340
end
341341

342+
describe '#public_commands' do
343+
let(:fixture) { :private_commands }
344+
345+
it 'returns an array of Command objects excluding private commands' do
346+
expect(subject.public_commands.count).to eq 1
347+
expect(subject.public_commands.first.name).to eq 'connect'
348+
end
349+
end
350+
351+
describe '#public_commands_aliases' do
352+
let(:fixture) { :private_commands }
353+
354+
it 'returns an array of command aliases of public subcommands' do
355+
expect(subject.public_command_aliases).to eq %w[connect c]
356+
end
357+
end
358+
342359
describe '#user_file_path' do
343360
it 'returns the path to the user file' do
344361
expect(subject.user_file_path 'test.sh').to eq 'spec/tmp/src/test.sh'

spec/fixtures/script/commands.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,19 @@
378378
short: -c
379379
allowed: [green, red]
380380

381+
:private_commands:
382+
name: private
383+
help: Test private commands
384+
commands:
385+
- name: connect
386+
alias: c
387+
- name: connect-ftp
388+
alias: cf
389+
private: true
390+
- name: connect-ssh
391+
alias: cf
392+
private: true
393+
381394
:repeatable_arg:
382395
name: get
383396
args:

0 commit comments

Comments
 (0)