選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

55 行
1.7 KiB

  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. let(:after_sourcing) do
  6. -> do
  7. session.run_command(history_strategy)
  8. end
  9. end
  10. it 'by default is determined by calling the `history` strategy function' do
  11. session.send_string('h')
  12. wait_for { session.content }.to eq('history')
  13. end
  14. context 'when ZSH_AUTOSUGGEST_STRATEGY is set to an array' do
  15. let(:after_sourcing) do
  16. -> do
  17. session.
  18. run_command(foobar_strategy).
  19. run_command(foobaz_strategy).
  20. run_command('ZSH_AUTOSUGGEST_STRATEGY=(foobar foobaz)')
  21. end
  22. end
  23. it 'is determined by the first strategy function to return a suggestion' do
  24. session.send_string('foo')
  25. wait_for { session.content }.to eq('foobar baz')
  26. session.send_string('baz')
  27. wait_for { session.content }.to eq('foobaz bar')
  28. end
  29. end
  30. context 'when ZSH_AUTOSUGGEST_STRATEGY is set to a string' do
  31. let(:after_sourcing) do
  32. -> do
  33. session.
  34. run_command(foobar_strategy).
  35. run_command(foobaz_strategy).
  36. run_command('ZSH_AUTOSUGGEST_STRATEGY="foobar foobaz"')
  37. end
  38. end
  39. it 'is determined by the first strategy function to return a suggestion' do
  40. session.send_string('foo')
  41. wait_for { session.content }.to eq('foobar baz')
  42. session.send_string('baz')
  43. wait_for { session.content }.to eq('foobaz bar')
  44. end
  45. end
  46. end