Skip to content

Commit 2c31052

Browse files
committed
rubocop
1 parent 5ce86fc commit 2c31052

4 files changed

Lines changed: 27 additions & 21 deletions

File tree

‎spec/bashly/completion_builder_spec.rb‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
describe CompletionBuilder do
2-
fixtures = load_fixture('completion_builder')
3-
42
describe '#call' do
5-
fixtures.each do |fixture, options|
3+
load_fixture('completion_builder').each do |fixture, options|
64
context "with :#{fixture}" do
75
let(:command) { Script::Command.new options['command'] }
86
let(:builder) do
@@ -18,6 +16,7 @@
1816
end
1917

2018
context 'with a default command' do
19+
let(:fixtures) { load_fixture('completion_builder') }
2120
let(:command) { Script::Command.new fixtures[:default_command]['command'] }
2221
let(:data) { described_class.new(command).call }
2322

‎spec/bashly/concerns/completions_command_spec.rb‎

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
let(:fixtures) { load_fixture('script/commands') }
55
let(:fixture) { :completions_simple }
6+
let(:completion_generator) { instance_double Completely::Completions }
67

78
describe '#completion_data' do
89
it 'returns a data structure for completely' do
@@ -11,17 +12,16 @@
1112
end
1213

1314
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)
2018
.and_return completion_generator
21-
expect(completion_generator).to receive(:wrapper_function)
19+
allow(completion_generator).to receive(:wrapper_function)
2220
.with('custom_name')
2321
.and_return 'wrapped completion script'
22+
end
2423

24+
it 'returns the generated bash completion script wrapped in a function' do
2525
expect(subject.completion_function('custom_name'))
2626
.to eq 'wrapped completion script'
2727
end
@@ -38,16 +38,15 @@
3838
end
3939

4040
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)
4744
.and_return completion_generator
48-
expect(completion_generator).to receive(:script)
45+
allow(completion_generator).to receive(:script)
4946
.and_return 'completion script'
47+
end
5048

49+
it 'returns the generated bash completion script' do
5150
expect(subject.completion_script)
5251
.to eq 'completion script'
5352
end

‎spec/bashly/libraries/completions_function_spec.rb‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
before { reset_tmp_dir example: 'minimal' }
77

88
describe '#files' do
9-
it 'returns an array with a single hash' do
9+
it 'returns one file at the default path' do
1010
files = subject.files
11-
content = files.first[:content]
1211

1312
expect(files.size).to eq 1
1413
expect(files.first[:path]).to eq "#{Settings.source_dir}/lib/send_completions.sh"
14+
end
15+
16+
it 'returns the completions function content' do
17+
content = subject.files.first[:content]
18+
1519
expect(content).to include '## [@bashly-upgrade completions send_completions]'
1620
expect(content).to include 'send_completions() {'
1721
expect(content).to include 'generated by'

‎spec/bashly/libraries/completions_script_spec.rb‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
before { reset_tmp_dir example: 'minimal' }
77

88
describe '#files' do
9-
it 'returns an array with a single hash' do
9+
it 'returns one file at the default path' do
1010
files = subject.files
11-
content = files.first[:content]
1211

1312
expect(files.size).to eq 1
1413
expect(files.first[:path]).to eq "#{Settings.target_dir}/completions.bash"
14+
end
15+
16+
it 'returns the completions script content' do
17+
content = subject.files.first[:content]
18+
1519
expect(content).to include '# download completion'
1620
expect(content).to include 'generated by'
1721
expect(content).to include 'completely'

0 commit comments

Comments
 (0)