File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33module Completely
44 module Commands
55 class Generate < Base
6- help 'Generate the bash completion script'
6+ help 'Generate the bash completion script to file or stdout '
77
88 usage 'completely generate [CONFIG_PATH OUTPUT_PATH --function NAME --wrap NAME]'
99 usage 'completely generate (-h|--help)'
Original file line number Diff line number Diff line change 33module Completely
44 module Commands
55 class Preview < Base
6- help 'Generate the bash completion script to STDOUT '
6+ help 'Generate the bash completion script to stdout '
77
88 usage 'completely preview [CONFIG_PATH --function NAME]'
99 usage 'completely preview (-h|--help)'
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ Completely - Bash Completions Generator
22
33Commands:
44 init Create a new sample YAML configuration file
5- preview Generate the bash completion script to STDOUT
6- generate Generate the bash completion script
5+ preview Generate the bash completion script to stdout
6+ generate Generate the bash completion script to file or stdout
77 test Test completions
88 install Install a bash completion script
99 uninstall Uninstall a bash completion script
Original file line number Diff line number Diff line change 1+ Saved spec/tmp/stdin-to-file.bash
Original file line number Diff line number Diff line change 1- Generate the bash completion script
1+ Generate the bash completion script to file or stdout
22
33Usage:
44 completely generate [CONFIG_PATH OUTPUT_PATH --function NAME --wrap NAME]
Original file line number Diff line number Diff line change 1- Generate the bash completion script to STDOUT
1+ Generate the bash completion script to stdout
22
33Usage:
44 completely preview [CONFIG_PATH --function NAME]
Original file line number Diff line number Diff line change 11describe Commands ::Generate do
22 subject { described_class . new }
33
4- before { system 'cp lib/completely/templates/sample.yaml completely.yaml' }
5- after { system 'rm -f completely.yaml' }
4+ before do
5+ reset_tmp_dir
6+ system 'cp lib/completely/templates/sample.yaml completely.yaml'
7+ end
8+
9+ after do
10+ system 'rm -f completely.yaml'
11+ end
612
713 context 'with --help' do
814 it 'shows long usage' do
8187 end
8288 end
8389
90+ context 'with stdin and stdout' do
91+ it 'reads config from stdin and writes to stdout' do
92+ allow ( $stdin) . to receive ( :tty? ) . and_return false
93+ allow ( $stdin) . to receive ( :read ) . and_return File . read ( 'completely.yaml' )
94+
95+ expect { subject . execute %w[ generate - ] }
96+ . to output_approval ( 'cli/generated-script' )
97+ end
98+ end
99+
100+ context 'with stdin and output path' do
101+ let ( :outfile ) { 'spec/tmp/stdin-to-file.bash' }
102+
103+ it 'reads config from stdin and writes to file' do
104+ allow ( $stdin) . to receive ( :tty? ) . and_return false
105+ allow ( $stdin) . to receive ( :read ) . and_return File . read ( 'completely.yaml' )
106+
107+ expect { subject . execute %W[ generate - #{ outfile } ] } . to output_approval ( 'cli/generate/custom-path-stdin' )
108+ expect ( File . read outfile ) . to match_approval ( 'cli/generated-script' )
109+ end
110+ end
111+
84112 context 'with --function NAME' do
85113 after { system 'rm -f completely.bash' }
86114
You can’t perform that action at this time.
0 commit comments