File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 33
44 let :mock_installer do
55 instance_double Installer ,
6- install : true ,
7- target_path : 'some-target-path' ,
6+ install : true ,
7+ target_path : 'some-target-path' ,
88 command_string : 'sudo cp source target'
99 end
1010
4242 end
4343 end
4444end
45-
Original file line number Diff line number Diff line change 2222 context 'when the user is root' do
2323 it 'returns the command without sudo' do
2424 allow ( subject ) . to receive ( :root_user? ) . and_return true
25-
25+
2626 expect ( subject . command ) . to eq %w[ cp completions.bash /usr/share/bash-completion/completions/completely-test ]
2727 end
2828 end
5252 context 'when the completions_path cannot be found' do
5353 it 'raises an error' do
5454 allow ( subject ) . to receive ( :completions_path ) . and_return nil
55-
55+
5656 expect { subject . install } . to raise_approval ( 'installer/install-no-dir' )
5757 end
5858 end
5959
6060 context 'when the script cannot be found' do
6161 it 'raises an error' do
6262 allow ( subject ) . to receive ( :script_path ) . and_return missing_file
63-
63+
6464 expect { subject . install } . to raise_approval ( 'installer/install-no-script' )
6565 end
6666 end
6767
6868 context 'when the target exists' do
6969 it 'raises an error' do
7070 allow ( subject ) . to receive ( :target_path ) . and_return existing_file
71-
71+
7272 expect { subject . install } . to raise_approval ( 'installer/install-target-exists' )
7373 end
7474 end
7575
7676 context 'when the target exists but force=true' do
7777 it 'proceeds to install' do
7878 allow ( subject ) . to receive ( :target_path ) . and_return existing_file
79-
79+
8080 expect ( subject ) . to receive ( :system ) . with ( *expected_command )
81-
81+
8282 subject . install force : true
8383 end
8484 end
8585
8686 context 'when the target does not exist' do
8787 it 'proceeds to install' do
8888 allow ( subject ) . to receive ( :target_path ) . and_return missing_file
89-
89+
9090 expect ( subject ) . to receive ( :system ) . with ( *expected_command )
91-
91+
9292 subject . install
9393 end
9494 end
You can’t perform that action at this time.
0 commit comments