|
3 | 3 |
|
4 | 4 | let(:fixtures) { load_fixture('script/commands') } |
5 | 5 | let(:fixture) { :completions_simple } |
| 6 | + let(:completion_generator) { instance_double Completely::Completions } |
6 | 7 |
|
7 | 8 | describe '#completion_data' do |
8 | 9 | it 'returns a data structure for completely' do |
|
11 | 12 | end |
12 | 13 |
|
13 | 14 | describe '#completion_function' do |
14 | | - it 'returns the generated bash completion script wrapped in a function' do |
15 | | - expected_data = subject.completion_data |
16 | | - completion_generator = instance_double Completely::Completions |
17 | | - |
18 | | - expect(Completely::Completions).to receive(:new) |
19 | | - .with(expected_data) |
| 15 | + before do |
| 16 | + allow(Completely::Completions).to receive(:new) |
| 17 | + .with(subject.completion_data) |
20 | 18 | .and_return completion_generator |
21 | | - expect(completion_generator).to receive(:wrapper_function) |
| 19 | + allow(completion_generator).to receive(:wrapper_function) |
22 | 20 | .with('custom_name') |
23 | 21 | .and_return 'wrapped completion script' |
| 22 | + end |
24 | 23 |
|
| 24 | + it 'returns the generated bash completion script wrapped in a function' do |
25 | 25 | expect(subject.completion_function('custom_name')) |
26 | 26 | .to eq 'wrapped completion script' |
27 | 27 | end |
|
38 | 38 | end |
39 | 39 |
|
40 | 40 | describe '#completion_script' do |
41 | | - it 'returns the generated bash completion script' do |
42 | | - expected_data = subject.completion_data |
43 | | - completion_generator = instance_double Completely::Completions |
44 | | - |
45 | | - expect(Completely::Completions).to receive(:new) |
46 | | - .with(expected_data) |
| 41 | + before do |
| 42 | + allow(Completely::Completions).to receive(:new) |
| 43 | + .with(subject.completion_data) |
47 | 44 | .and_return completion_generator |
48 | | - expect(completion_generator).to receive(:script) |
| 45 | + allow(completion_generator).to receive(:script) |
49 | 46 | .and_return 'completion script' |
| 47 | + end |
50 | 48 |
|
| 49 | + it 'returns the generated bash completion script' do |
51 | 50 | expect(subject.completion_script) |
52 | 51 | .to eq 'completion script' |
53 | 52 | end |
|
0 commit comments