Mercurial > dotfiles
comparison .zfun/zsh-autosuggestions/spec/options/strategy_spec.rb @ 467:e1ce8897030d
zsh: import df6f6f9ff41 of zsh-autosuggestions
| author | Augie Fackler <raf@durin42.com> |
|---|---|
| date | Mon, 03 Dec 2018 22:37:29 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 466:f248cf012d9a | 467:e1ce8897030d |
|---|---|
| 1 describe 'a suggestion for a given prefix' do | |
| 2 let(:history_strategy) { '_zsh_autosuggest_strategy_history() { suggestion="history" }' } | |
| 3 let(:foobar_strategy) { '_zsh_autosuggest_strategy_foobar() { [[ "foobar baz" = $1* ]] && suggestion="foobar baz" }' } | |
| 4 let(:foobaz_strategy) { '_zsh_autosuggest_strategy_foobaz() { [[ "foobaz bar" = $1* ]] && suggestion="foobaz bar" }' } | |
| 5 | |
| 6 let(:after_sourcing) do | |
| 7 -> do | |
| 8 session.run_command(history_strategy) | |
| 9 end | |
| 10 end | |
| 11 | |
| 12 it 'by default is determined by calling the `history` strategy function' do | |
| 13 session.send_string('h') | |
| 14 wait_for { session.content }.to eq('history') | |
| 15 end | |
| 16 | |
| 17 context 'when ZSH_AUTOSUGGEST_STRATEGY is set to an array' do | |
| 18 let(:after_sourcing) do | |
| 19 -> do | |
| 20 session. | |
| 21 run_command(foobar_strategy). | |
| 22 run_command(foobaz_strategy). | |
| 23 run_command('ZSH_AUTOSUGGEST_STRATEGY=(foobar foobaz)') | |
| 24 end | |
| 25 end | |
| 26 | |
| 27 it 'is determined by the first strategy function to return a suggestion' do | |
| 28 session.send_string('foo') | |
| 29 wait_for { session.content }.to eq('foobar baz') | |
| 30 | |
| 31 session.send_string('baz') | |
| 32 wait_for { session.content }.to eq('foobaz bar') | |
| 33 end | |
| 34 end | |
| 35 | |
| 36 context 'when ZSH_AUTOSUGGEST_STRATEGY is set to a string' do | |
| 37 let(:after_sourcing) do | |
| 38 -> do | |
| 39 session. | |
| 40 run_command(foobar_strategy). | |
| 41 run_command(foobaz_strategy). | |
| 42 run_command('ZSH_AUTOSUGGEST_STRATEGY="foobar foobaz"') | |
| 43 end | |
| 44 end | |
| 45 | |
| 46 it 'is determined by the first strategy function to return a suggestion' do | |
| 47 session.send_string('foo') | |
| 48 wait_for { session.content }.to eq('foobar baz') | |
| 49 | |
| 50 session.send_string('baz') | |
| 51 wait_for { session.content }.to eq('foobaz bar') | |
| 52 end | |
| 53 end | |
| 54 end | |
| 55 |
