Account for fuzzy completions.

Introduced in Fish 3.1
cf. https://github.com/fish-shell/fish-shell/issues/5467

Needed to make tests less strict.
Instead of checking the exact list of matches,
we require the expected ones and exclude some others.
This commit is contained in:
Raphael Reitzig 2020-05-26 00:00:04 +02:00
parent 0c15f199cd
commit 479fa1e541
4 changed files with 154 additions and 115 deletions

View file

@ -7,12 +7,8 @@ module CompletionHelper
completions = run_fish_command("complete -C\"sdk #{cmd}\"")
completions.split("\n") \
.map { |line| line.split(/\s+/)[0].strip } \
.sort \
.uniq \
.join(', ')
.map { |line| line.split(/\s+/)[0].strip }
# TODO: Why do we get duplicates in the Docker container?
# --> remove uniq
end
end
World CompletionHelper
@ -21,6 +17,15 @@ When('the user enters {string} into the prompt') do |cmd|
@response = complete(cmd.gsub(/["']/, ''))
end
Then(/^completion should propose "(.*)"$/) do |completions|
expect(@response).to eq(completions)
Then('completion should propose {string}') do |completions|
completions = completions.split(',').map(&:strip)
expect(@response).to include(*completions)
end
Then('completion should not propose {patterns}') do |exclusions_patterns|
exclusions_patterns.each do |p|
@response.each do |r|
expect(r).not_to match(p)
end
end
end