Skip to content

Commit b6a006b

Browse files
committed
add specs for generate --install
1 parent 63eac42 commit b6a006b

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

lib/completely/commands/generate.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def install(content)
5454
installer = Installer.from_string program: args['--install'], string: content
5555
success = installer.install force: true
5656
raise InstallError, "Failed running command:\nnb`#{installer.install_command_string}`" unless success
57+
5758
say "Saved m`#{installer.target_path}`"
5859
say 'You may need to restart your session to test it'
5960
end
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Saved stubbed target_path
2+
You may need to restart your session to test it

spec/completely/commands/generate_spec.rb

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,28 @@
116116
end
117117
end
118118

119-
context 'with --wrapper NAME' do
119+
context 'with --install PROGRAM' do
120+
let(:mock_installer) do
121+
instance_double Installer,
122+
install: true,
123+
install_command_string: 'stubbed install_command_string',
124+
target_path: 'stubbed target_path'
125+
end
126+
127+
it 'passes the generated script to the installer' do
128+
allow(Installer).to receive(:from_string)
129+
.with(
130+
program: 'mycli',
131+
string: a_string_matching(/bash completions script/)
132+
).and_return(mock_installer)
133+
134+
expect(mock_installer).to receive(:install)
135+
136+
expect { subject.execute %w[generate --install mycli] }.to output_approval('cli/generate/install')
137+
end
138+
end
139+
140+
context 'with --wrap NAME' do
120141
after { system 'rm -f completely.bash' }
121142

122143
it 'wraps the script in a function' do

0 commit comments

Comments
 (0)