|
5 | 5 |
|
6 | 6 | context 'with --help' do |
7 | 7 | it 'shows long usage' do |
8 | | - expect { subject.execute %w[install --help] }.to output_approval('cli/install/help').diff(10) |
| 8 | + expect { subject.execute %w[install --help] } |
| 9 | + .to output_approval('cli/install/help').diff(10) |
9 | 10 | end |
10 | 11 | end |
11 | 12 |
|
12 | 13 | context 'without arguments' do |
13 | 14 | it 'shows short usage' do |
14 | | - expect { subject.execute %w[install] }.to output_approval('cli/install/no-args') |
| 15 | + expect { subject.execute %w[install] } |
| 16 | + .to output_approval('cli/install/no-args') |
15 | 17 | end |
16 | 18 | end |
17 | 19 |
|
18 | 20 | context 'with only the program name argument' do |
19 | 21 | context 'when the default script is not found' do |
20 | 22 | it 'raises an error' do |
21 | | - expect { subject.execute %w[install completely-test] }.to raise_approval('cli/install/missing-script') |
| 23 | + expect { subject.execute %w[install completely-test] } |
| 24 | + .to raise_approval('cli/install/missing-script') |
22 | 25 | end |
23 | 26 | end |
24 | 27 |
|
25 | 28 | context 'when the default script is found' do |
26 | | - let(:expected_args) { |
| 29 | + let(:expected_args) do |
27 | 30 | %w[ |
28 | 31 | sudo |
29 | 32 | cp |
30 | 33 | completely.bash |
31 | 34 | /usr/share/bash-completion/completions/completely-test |
32 | 35 | ] |
33 | | - } |
| 36 | + end |
34 | 37 |
|
35 | 38 | before do |
36 | 39 | reset_tmp_dir |
|
39 | 42 |
|
40 | 43 | it 'copies the script' do |
41 | 44 | Dir.chdir 'spec/tmp' do |
42 | | - expect(subject).to receive(:system).with(*expected_args).and_return true |
43 | | - expect { subject.execute %W[install completely-test] }.to output_approval('cli/install/install-default') |
| 45 | + allow(subject).to receive(:system).with(*expected_args).and_return true |
| 46 | + expect { subject.execute %w[install completely-test] } |
| 47 | + .to output_approval('cli/install/install-default') |
44 | 48 | end |
45 | 49 | end |
46 | 50 | end |
47 | 51 | end |
48 | 52 |
|
49 | 53 | context 'with the program name argument and a script argument' do |
50 | | - let(:expected_args) { |
| 54 | + let(:expected_args) do |
51 | 55 | %w[ |
52 | 56 | sudo |
53 | 57 | cp |
54 | 58 | README.md |
55 | 59 | /usr/share/bash-completion/completions/completely-test |
56 | 60 | ] |
57 | | - } |
| 61 | + end |
58 | 62 |
|
59 | 63 | it 'copies the script' do |
60 | | - expect(subject).to receive(:system).with(*expected_args).and_return true |
61 | | - expect { subject.execute %W[install completely-test README.md] }.to output_approval('cli/install/install-specified') |
| 64 | + allow(subject).to receive(:system).with(*expected_args).and_return true |
| 65 | + expect { subject.execute %w[install completely-test README.md] } |
| 66 | + .to output_approval('cli/install/install-specified') |
| 67 | + end |
| 68 | + end |
| 69 | + |
| 70 | + context 'with --dry' do |
| 71 | + it 'shows the command' do |
| 72 | + expect { subject.execute %w[install completely-test README.md --dry] } |
| 73 | + .to output_approval('cli/install/dry') |
62 | 74 | end |
63 | 75 | end |
64 | 76 |
|
65 | 77 | context 'when none of the target directories is found' do |
66 | 78 | it 'raises an error' do |
67 | | - expect(subject).to receive(:completions_path).and_return nil |
68 | | - expect { subject.execute %W[install completely-test README.md] }.to raise_approval('cli/install/no-completion-targets') |
| 79 | + allow(subject).to receive(:completions_path).and_return nil |
| 80 | + expect { subject.execute %w[install completely-test README.md] } |
| 81 | + .to raise_approval('cli/install/no-completion-targets') |
69 | 82 | end |
70 | 83 | end |
71 | 84 |
|
72 | 85 | context 'when the target file exists' do |
73 | 86 | it 'raises an error' do |
74 | | - expect(subject).to receive(:target_exist?).and_return true |
75 | | - expect { subject.execute %W[install completely-test README.md] }.to raise_approval('cli/install/target-exists') |
| 87 | + allow(subject).to receive(:target_exist?).and_return true |
| 88 | + expect { subject.execute %w[install completely-test README.md] } |
| 89 | + .to raise_approval('cli/install/target-exists') |
76 | 90 | end |
77 | 91 | end |
78 | 92 | end |
0 commit comments